Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10799

Re: Creating a Scatter Plot with Labeled Points

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Creating a Scatter Plot with Labeled Points
Date 2012-07-05 10:15 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jt3pfr$139$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 7/4/12 at 3:29 AM, sandwaterhand@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]]}]

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Creating a Scatter Plot with Labeled Points Bill Rowe <readnews@sbcglobal.net> - 2012-07-05 10:15 +0000

csiph-web