1
$\begingroup$

Possible Duplicate:
Creating legends for plots with multiple lines?

I have a ListPlot of data points. To distinguish between datapoints coming from different sources, I give them different PlotMarkers, say green triangles for one, and red circles for another. An example could be:

Jones2012 = {{3, 2.5}, {2, 4}};
Adams1999 = {{1, 2}, {4, 4}};
ListPlot[{Jones2012, Adams1999}, Frame -> True, 
 PlotMarkers -> {{\[FilledCircle], 20}, {\[FilledUpTriangle], 20}}, 
 PlotStyle -> {Red, Darker[Green]}, 
 PlotRange -> {{0, 5}, {0, 5}}]

Now I want to have a small box in the upper right corner explaining what data the different markers correspond to, e.g. Jones 2012 is marked with red circles. I am thinking that the best way to do it would be to make a box as an object first, then insert this object in the graphics afterwards. My best try at making the box so far is:

triangle = 
 Graphics[{Thick, Darker[Green], Polygon[{{0, 0}, {1, 0}, {0.5, 1}}]},
   ImageSize -> 10]
circle = Graphics[{Thick, Red, Disk[{0, 0}]}, ImageSize -> 10];
box = Framed@
  Text[Style[triangle "Jones 2012" circle "Adams 1999", 12]]

or

box = Framed@
  Text[Style[triangle "Jones 2012 \nAdams 1999" circle, 12]]

But what I would like to do is to have the symbols first on the line, followed by what it represents, then a new line with the next data set. So something like:

"green triangle" Adams 1999

"red circle" Jones 2012

Preferably the symbols would be aligned, as well as the left edge of the text. I feel like I should be close, but can't seem to figure out that last little thing to get it how I want it.

Thanks so much!

$\endgroup$
4
  • 2
    $\begingroup$ You want a plot label. See this question for a very flexible plot label maker. I would say this is a duplicate of that (unless if you're just interested in fixing your attempt) $\endgroup$
    – rm -rf
    Oct 5, 2012 at 17:52
  • $\begingroup$ @rm-rf It seems to me that what the OP wants is fully covered in your linked answer. Voting to close. $\endgroup$ Oct 5, 2012 at 18:41
  • $\begingroup$ @rm-rf Yes, this is very close to what I want, and will very likely be useful also in the future. Sorry that I didn't see this before, and thank you guys for your help. $\endgroup$
    – GOt
    Oct 5, 2012 at 20:18
  • $\begingroup$ You're welcome :) $\endgroup$
    – rm -rf
    Oct 5, 2012 at 20:24

0

Browse other questions tagged or ask your own question.