On 7/4/12 at 3:29 AM, sandwaterhand at gmail.com (Mike McCraith) wrote:
>Hello there. I'm trying to graph a Scatter Plot based on a given
>list of data and have the coordinates appear near the point.
>I'm trying to save time and, instead of manually typing the text for
>the coordinates, I'd like to be able to pull the coordinates from
>the list to plot them point and list the text. Here's what I have
>so far:
>S11Exercise64b = {{0, 120}, {10, 119}, {20, 118}, {30, 117}, {40, 116},
>{50, 115}, {60, 114}, {70, 113}, {80, 112}};
<code snipped>
Try something like this:
ListPlot[S11Exercise64b, AxesLabel -> {x, y}, AxesOrigin -> {0, 0},
PlotStyle -> {Blue, PointSize[.02]},
Epilog -> {Text[#, {1, .95} #] & /@
S11Exercise64b[[2 ;; -1 ;; 2]]}]
I've set this to label every other point since labeling each
point makes it difficult to read the labels. If you need to see
coordinates for every point in a plot with many points, look at
using ToolTip to display the coordinates of a point when you
hover your mouse over that point.
Note, the usage of PlotStyle. It makes no sense to have ListPlot
plot the data and use the Epilog directive to re-plot the same
data with a larger point size or different color. You are
essentially plotting the data twice. It is far more efficient to
use the directive PlotStyle to specify point size, color etc. so
that data points are plotted once with the desired attributes.
Or if you wanted a larger font for the labels
ListPlot[S11Exercise64b, AxesLabel -> {x, y}, AxesOrigin -> {0, 0},
PlotStyle -> {Blue, PointSize[.02]},
Epilog -> {Text[Style[#,16], {1, .95} #] & /@
S11Exercise64b[[2 ;; -1 ;; 2]]}]
Or to use () instead of {}
ListPlot[S11Exercise64b, AxesLabel -> {x, y}, AxesOrigin -> {0, 0},
PlotStyle -> {Blue, PointSize[.02]},
Epilog -> {Text[
Style["(" <> StringTake[ToString@#, {2, -2}] <> ")",
16], {1, .9} #] & /@ S11Exercise64b[[2 ;; -1 ;; 2]]}]