# Displaying coordinates on graph

**URL:** <https://community.wolfram.com/t/displaying-coordinates-on-graph/18976>\
**Category:** Questions\
**Tags:** graphics-and-visualization, interface-construction\
**Created:** [October 15, 2021, 4:56am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976 "2021-10-15T04:56:24Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![manojimrith](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manojimrith](https://community.wolfram.com/u/manojimrith)\
**Post date:** [October 15, 2021, 4:56am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/1 "2021-10-15T04:56:24Z")

</div>

Dear Members,  
I require that the coordinates display on the graph as the intersection move dynamically.  
Thank you for your usual help.

```
Manipulate[ContourPlot[{
   -5 v1 - 82 v2 == (v3 - 522),
   -1.25 v1 - 4.45 v2 == (v4 - 263)},
  {v1, 10, 50},
  {v2, 2, 5},
  PlotLegends -> Placed[{"a58", "a60"}, Above],
  FrameLabel -> {"X", "Y"},
  Axes -> True,
  Frame -> True],
 {{v3, 94, "a58"}, 6, 892, Appearance -> "Open"},
 {{v4, 165, "a60"}, 165, 270, Appearance -> "Open"},
 ControlPlacement -> Left]

```

---

<div class="post-metadata">

**Author:** ![hansmilton](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hansmilton/32/8656_2.png) [@hansmilton](https://community.wolfram.com/u/hansmilton)\
**Post date:** [October 15, 2021, 5:18pm UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/2 "2021-10-15T17:18:30Z")

</div>

Manipulate[  
intersection = NSolveValues[{-5 x - 82 y == v3 - 522, -1.25 x - 4.45 y == v4 - 263}, {x, y}];  
ContourPlot[  
{-5 v1 - 82 v2 == (v3 - 522), -1.25 v1 - 4.45 v2 == (v4 - 263)},  
{v1, 10, 50}, {v2, 2, 5},  
PlotLegends → Placed[{“a58”, “a60”}, Above], FrameLabel → {“X”, “Y”},  
Axes → True, Frame → True, PlotLabel → intersection  
],  
{{v3, 94, “a58”}, 6, 892, Appearance → “Open”},  
{{v4, 165, “a60”}, 165, 270, Appearance → “Open”},  
{intersection, None},  
ControlPlacement → Left  
]

---

<div class="post-metadata">

**Author:** ![manojimrith](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manojimrith](https://community.wolfram.com/u/manojimrith)\
**Post date:** [October 16, 2021, 3:18am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/3 "2021-10-16T03:18:50Z")

</div>

Dear Sir,  
Thank you for your response  
I am trying to get something like the example image attached.  
The coordinates can be either on the graph itself or on the left

 ![9845.JPG](https://global.discourse-cdn.com/wolfram/original/3X/b/a/ba993473e091a9edaf19dcec7435c5e316dfade9.jpeg)

 ![9845.JPG](https://global.discourse-cdn.com/wolfram/original/3X/b/a/ba993473e091a9edaf19dcec7435c5e316dfade9.jpeg)

---

<div class="post-metadata">

**Author:** ![hansmilton](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hansmilton/32/8656_2.png) [@hansmilton](https://community.wolfram.com/u/hansmilton)\
**Post date:** [October 16, 2021, 7:04am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/4 "2021-10-16T07:04:38Z")

</div>

OK, here is a version with coordinates at the left

```
Manipulate[
 	isect = {x, y} /. NSolve[{-5 x - 82 y == v3 - 522, -1.25 x - 4.45 y == v4 - 263}, {x, y}] // First;
 	coords = Grid[{{"X:", First@isect}, {"Y:", Last@isect}}, Alignment -> "."];
 	ContourPlot[
  		{-5 v1 - 82 v2 == (v3 - 522), -1.25 v1 - 4.45 v2 == (v4 - 263)},
  		{v1, 10, 50}, {v2, 2, 5},
  		PlotLegends -> Placed[{"a58", "a60"}, Above], FrameLabel -> {"X", "Y"},
  		Axes -> True, Frame -> True
  	],
 	{{v3, 94, "a58"}, 6, 892, Appearance -> "Open"},
 	{{v4, 165, "a60"}, 165, 270, Appearance -> "Open"},
 	{isect, None}, {coords, None},
 	Delimiter, Spacer@{0, 50},
 	Style[Dynamic[coords], 14] // Framed,
 	ControlPlacement -> Left, TrackedSymbols :> {v3, v4}
 ]

```

---

<div class="post-metadata">

**Author:** ![manojimrith](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manojimrith](https://community.wolfram.com/u/manojimrith)\
**Post date:** [October 18, 2021, 3:44am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/5 "2021-10-18T03:44:48Z")

</div>

Dear Sir,  
Thank you very much.  
Grateful for your help.

---

<div class="post-metadata">

**Author:** ![manojimrith](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manojimrith](https://community.wolfram.com/u/manojimrith)\
**Post date:** [November 15, 2021, 10:37pm UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/6 "2021-11-15T22:37:45Z")

</div>

Dear Sir,  
Trust you are well.  
In the previous program, I’ve been trying to set the solution to be displayed at 3 decimal places.  
I’ve tried with:

```
NSolve[{-5 x - 82 y == v3 - 522, -1.25 x - 4.45 y == v4 - 263}, {x, 
  y}, Reals, 3]

NSolve[{-5 x - 82 y == v3 - 522, -1.25 x - 4.45 y == v4 - 263}, {x, 
  y}, WorkingPrecision -> 3]

```

But none are giving the output at 3 decimal places.  
Grateful for your time and your help.  
Thanks and regards.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [November 16, 2021, 12:43am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/7 "2021-11-16T00:43:18Z")

</div>

You can use `NumberForm`. e.g.

```
With[{v3 = 6, v4 = 190}, 
   {x, y} /. 
    NSolve[{-5 x - 82 y == v3 - 522, -1.25 x - 4.45 y == v4 - 263}, {x, y}]] // First // 
    NumberForm[#, {Infinity, 3}] &
(* {45.979, 3.489} *)

```

As with most form wrappers, the result cannot be used in subsequent computations, it is for display only. So used `NumberForm` on `First@isect` and `Last@isect`.

---

<div class="post-metadata">

**Author:** ![manojimrith](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manojimrith](https://community.wolfram.com/u/manojimrith)\
**Post date:** [November 16, 2021, 3:28am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/8 "2021-11-16T03:28:25Z")

</div>

Thanks for prompt reply Prof.  
However as I included in the program, It doesn’t working.  
Kindly revert me for resolve. Thanks.

```
Manipulate[With[{v3 = 6, v4 = 190},
  isect = {x, y} /.
      NSolve[
       {-5 x - 82 y == v3 - 522,
        -1.25 x - 4.45 y == v4 - 263},
       {x, y}] // First // NumberForm[#, {Infinity, 2}] &;
  coords = 
   Grid[{{"X:", First@isect}, {"Y:", Last@isect}}, Alignment -> "."]];
 
 ContourPlot[
  {-5 v1 - 82 v2 == (v3 - 522),
   -1.25 v1 - 4.45 v2 == (v4 - 263)},
  {v1, 10, 50}, {v2, 2, 5},
  PlotLegends -> Placed[{"a58", "a60"}, Above],
  FrameLabel -> {"X", "Y"},
  Axes -> True, Frame -> True],
 {{v3, 94, "a58"}, 6, 892, Appearance -> "Open"},
 {{v4, 165, "a60"}, 165, 270, Appearance -> "Open"},
 {isect, None}, {coords, None},
 Delimiter, Spacer@{0, 50},
 Style[Dynamic[coords], 18] // Framed, ControlPlacement -> Left]

```

---

<div class="post-metadata">

**Author:** ![hansmilton](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hansmilton/32/8656_2.png) [@hansmilton](https://community.wolfram.com/u/hansmilton)\
**Post date:** [November 16, 2021, 8:43am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/9 "2021-11-16T08:43:30Z")

</div>

Try the code below. Besides the 3 decimals issue I have also moved the coordinate display to the center, should you think that looks better.

```
Manipulate[
 	isect = {x, y} /. NSolve[{-5 x - 82 y == v3 - 522, -1.25 x - 4.45 y == v4 - 263}, {x, y}] // First;
 	isect = NumberForm[#, {Infinity, 3}] & /@ isect;
 	coords = Grid[{{"X:", First@isect}, {"Y:", Last@isect}}, Alignment -> "."];
 	ContourPlot[
  		{-5 v1 - 82 v2 == (v3 - 522), -1.25 v1 - 4.45 v2 == (v4 - 263)},
  		{v1, 10, 50}, {v2, 2, 5},
  		PlotLegends -> Placed[{"a58", "a60"}, Above], FrameLabel -> {"X", "Y"},
  		Axes -> True, Frame -> True
  	],
 	{{v3, 94, "a58"}, 6, 892, Appearance -> "Open"},
 	{{v4, 165, "a60"}, 165, 270, Appearance -> "Open"},
 	{isect, None}, {coords, None},
 	Delimiter, Spacer@{0, 50},
 	Item[Style[Dynamic[coords], 14] // Framed, Alignment -> Center],
 	ControlPlacement -> Left, TrackedSymbols :> {v3, v4}
 ]

```

---

<div class="post-metadata">

**Author:** ![mfroeling](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mfroeling/32/23010_2.png) [@mfroeling](https://community.wolfram.com/u/mfroeling)\
**Post date:** [November 16, 2021, 9:40am UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/10 "2021-11-16T09:40:25Z")

</div>

num = NumberForm[#, {Infinity, 3}] &;

```
Manipulate[
 isect = {x, y} /. 
    NSolve[{-5 x - 82 y == v3 - 522, -1.25 x - 4.45 y == 
       v4 - 263}, {x, y}] // First;
 coords = Grid[Thread[{{"X:", "Y:"}, num /@ isect}], Alignment -> "."];
 
 ContourPlot[
  {-5 v1 - 82 v2 == (v3 - 522), -1.25 v1 - 4.45 v2 == (v4 - 263)},
  {v1, 10, 50}, {v2, 2, 5},
  PlotLegends -> Placed[{"a58", "a60"}, Above], 
  FrameLabel -> {"X", "Y"}, Axes -> True, Frame -> True, 
  Epilog -> 
   First@ListPlot[{Callout[isect, coords]}, 
     PlotRange -> {{10, 50}, {2, 5}}, 
     PlotStyle -> Directive[Large, Red]]]
 ,
 {{v3, 94, "a58"}, 6, 892, Appearance -> "Open"},
 {{v4, 165, "a60"}, 165, 270, Appearance -> "Open"},
 {isect, None},
 {coords, None},
 Delimiter,
 Spacer@{0, 50}, 
 Item[Style[Dynamic[coords], 14] // Framed, Alignment -> Center],
 ControlPlacement -> Left,
 TrackedSymbols :> {v3, v4}]

```

Using Epilog with Callout you can have your coords in the plot

 ![callout.png](https://global.discourse-cdn.com/wolfram/original/3X/7/1/7150f44d69b0debf7588072a15b8186f3e17e3d3.png)

---

<div class="post-metadata">

**Author:** ![manojimrith](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manojimrith](https://community.wolfram.com/u/manojimrith)\
**Post date:** [November 16, 2021, 1:38pm UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/11 "2021-11-16T13:38:03Z")

</div>

Dear Prof. Milton,  
Thank you very much. Works wonderfully

---

<div class="post-metadata">

**Author:** ![manojimrith](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manojimrith](https://community.wolfram.com/u/manojimrith)\
**Post date:** [November 16, 2021, 1:39pm UTC](https://community.wolfram.com/t/displaying-coordinates-on-graph/18976/12 "2021-11-16T13:39:26Z")

</div>

Dear Prof. Froeling,  
Thank you very much for your suggestion. I’ll implement same in the code.
