Mathematica Asked by Shb on August 15, 2021
Let’s say I have a listplot like so:
ListPlot[Prime[Range[25]]]
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:
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?
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:
Answered by Shb on August 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP