# axis values for custom points in listplot

Let's say I have a listplot like so:

ListPlot[Prime[Range]]


I want my plot to mark the x,y values for the values associated with say, the 5th, and 10th points in the input. I would be interested in any of the following:

• marking simply the y values so have 11 and 29 in the y axis
• marking both x and y axis: ie show {5,11} and {10,29} in the x and y axis respectively.

with, or without perpendicular lines connecting the points to axes.

The point of this, is to give the reader of the plot, a sense of scale for given points of interest.

Do I have to superimpose different plots on each other or can I do it by some config on the listplot itself?

• Use Ticks ? For example: ListPlot[Prime[Range], Ticks -> {{5, 10}, Prime[{5, 10}]}, Epilog -> {Gray, Dashed, Line[{{5, 0}, {5, Prime}}], Line[{{10, 0}, {10, Prime}}], Line[{{0, Prime}, {5, Prime}}], Line[{{0, Prime}, {10, Prime}}] }] – flinty Jul 15 '20 at 22:28
• ah! how did I miss that! yeah that would do the trick :) – Shb Jul 15 '20 at 22:31
• This is a bit more general: With[{points = {5, 10, 13}}, ListPlot[Prime[Range], Ticks -> {points, Prime[points]}, Epilog -> {Gray, Dashed, {Line[{{#, 0}, {#, Prime[#]}}], Line[{{0, Prime[#]}, {#, Prime[#]}}]} & /@ points }]] – flinty Jul 15 '20 at 22:31
• @flinty little improvement on this ^ mathematica.stackexchange.com/a/226205/8988 – Shb Jul 19 '20 at 18:22

## 1 Answer

This is a more readable and reusable version of the suggestion by @fliny

With[
{
points = Table[{n,Fibonacci[n]}, {n, 7}],
sampleValues = {1,5,7}
},
ListPlot[
points,
Joined -> True,
Ticks -> {sampleValues , points[[All,2]][[sampleValues]]},
Epilog -> {
Dashed,
{
Line[{Projection[points[[#]], {1,0}], points[[#]]}], (*X-axis projection*)
Line[{Projection[points[[#]], {0,1}], points[[#]]}]  (*Y-axis projection*)
} & /@ sampleValues
}
]
]


it will produce the following: 