Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Creating a Scatter Plot with Labeled Points

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127174] Re: Creating a Scatter Plot with Labeled Points
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Thu, 5 Jul 2012 06:12:15 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <5694614.26862.1341391328927.JavaMail.root@m06>

In this case at least, throw ListPlot into the ashcan.  Instead use Graphics
and just Map the desired point display onto the coordinate list.

S11Exercise64b = {{0, 120}, {10, 119}, {20, 118}, {30, 117}, {40, 
    116}, {50, 115}, {60, 114}, {70, 113}, {80, 112}}; 

If the plot is going to be viewed in Mathematica then I think the best
solution might be to put a Tooltip on each point.

Graphics[
 {AbsolutePointSize[4],
  Tooltip[Point[#], #] & /@ S11Exercise64b},
 AspectRatio -> 1/2,
 PlotRange -> {{-5, 85}, {100, 130}},
 PlotRangePadding -> Automatic,
 Axes -> True, AxesLabel -> {x, y}, AxesOrigin -> {-5, 100}] 

If you want to "print" the coordinates next to the point you could use:

Graphics[
 {AbsolutePointSize[4],
  {Point[#], Text[#, #, {0, -2}]} & /@ S11Exercise64b},
 AspectRatio -> 1/2,
 PlotRange -> {{-5, 85}, {100, 130}},
 PlotRangePadding -> Automatic,
 Axes -> True, AxesLabel -> {x, y}, AxesOrigin -> {-5, 100},
 ImageSize -> 600] 

But there I had to increase the ImageSize to keep the labels from cluttering
each other. As an alternative we could print the coordinates vertically. 

Graphics[
 {AbsolutePointSize[4],
  {Point[#], Text[#, #, {-1.2, 0}, {0, 1}]} & /@ S11Exercise64b},
 AspectRatio -> 1/2,
 PlotRange -> {{-5, 85}, {100, 130}},
 PlotRangePadding -> Automatic,
 Axes -> True, AxesLabel -> {x, y}, AxesOrigin -> {-5, 100},
 ImageSize -> 400] 

As well as Tooltips there are probably other less intrusive methods to
present the coordinates. One would be to draw faint lines to the coordinate
axes. 

Graphics[
 {{GrayLevel[0.9], 
     Line[{# {0, 1} - {5, 0}, #, # {1, 0} + {0, 111}}]} & /@ 
   S11Exercise64b,
  AbsolutePointSize[4],
  Point[#] & /@ S11Exercise64b},
 AspectRatio -> 1,
 PlotRange -> {{-5, 85}, {111, 121}},
 PlotRangePadding -> Automatic,
 Frame -> True, FrameLabel -> {x, y},
 FrameTicks -> Automatic,
 ImageSize -> 400] 

If the points are not so evenly spaced one could use data based ticks where
the tick labels and positions are at the point coordinate positions.

Another possibility is to present the data in both a plot and in a formatted
table.


David Park
djmpark at comcast.net 
http://home.comcast.net/~djmpark/index.html 


 

From: Mike McCraith [mailto:sandwaterhand at gmail.com] 



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}}; ListPlot[S11Exercise64b, AxesLabel
-> {x, y}, AxesOrigin -> {0, 0},  Epilog -> {Blue, PointSize[.02],
Point[S11Exercise64b],
   Text[Style[
     "(" && S11Exercise64b[[1, 1]] && "," && S11Exercise64b[[1, 2]] && ")",
FontSize -> 18], {.9*S11Exercise64b[[1, 1]] + 30, .9*S11Exercise64b[[1, 2]]
+ .2}],
   }
 ]


Please note, for this example, I am the first point (0, 120).

The line that begins with the "(" && S11Exercise64b...is my attempt to
extract the coordinates from the given list.  Thus, next to the point, it
should read (0,120).  However, I am getting ( ^ 0^, ^ 120 ^).  Basically, my
lack of knowledge concerning strings is one of my issues.

But, as you can see, once fixed, I'd have to create a Text[Style[ line for
every ordered pair that I have in the list.  Is there a way to automate this
process?  Again, a lack of know-how leads to now knowing how to do For
loops.

Any help is always greatly appreciated.

Thanks in advance!

Mike




  • Prev by Date: Re: Creating a Scatter Plot with Labeled Points
  • Next by Date: Re: Creating a Scatter Plot with Labeled Points
  • Previous by thread: Re: Creating a Scatter Plot with Labeled Points
  • Next by thread: Re: Creating a Scatter Plot with Labeled Points