Re: Hi, a simple question, thanks
- To: mathgroup at smc.vnet.net
- Subject: [mg59960] Re: [mg59905] Hi, a simple question, thanks
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Fri, 26 Aug 2005 04:53:59 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Jing, > I want to label every curve with ListPlot or MultipleListPLot, but by > using PlotLabel -> StyleForm[TraditionalForm["b971"],...] it can only > put the label in oneline in the middle. But I need it label every > curve, something as done by gnuplot. ... But looking at the online help for PlotLabel should have told you that there was no way that this was going to work, since PlotLabel gives the label for the overall plot. I won't comment on what GNUPlot does since this forum is about Mathematica. However, there are at least two ways to label each curve. The simplest, using MultipleListPlot, is to use PlotLegend, although results aren't particularly pleasing using defaults. No real matter, since you can eventually get something worthwhile using one (actually, all or most) of the myriad of options for Legend. For example, generate some data & labels. data = Table[{x, Sin[# Pi x]}, {x, -Pi, Pi, Pi/32}] & /@ Range[1, 2]; labl = StringJoin["Sin[", ToString[#], " ð x]"] & /@ Range[1, 2]; Using the default gives you MultipleListPlot[data, PlotLegend -> labl, PlotLabel->"My Plot"]; Although MultipleListPlot[data, PlotLabel->"My Plot", FrameTicks -> {PiScale, Automatic, None, None}, FrameLabel -> {"X axis", "Y axis"}, PlotLegend -> labl, LegendLabel -> "Curve", LegendOrientation -> Horizontal, LegendSize -> {.75, .2}, LegendPosition -> {-0.3, -.85}]; Might look better to some eyes. Numbers in LegendSize & Position need to be worked out; this is the least pleasant part of the exercise. Another method of labeling each curve is through Epilog and we will label the last point of each curve. The last point is obtained using lpts = Last[#] & /@ data; We can turn this into a simple label using simpl = Text[labl[[#]], lpts[[#]], {1, 0}] & /@ Range[1, 2]; Or a fancy one using fancy = Text[StyleForm[labl[[#]], FontWeight -> "Bold", FontSlant -> "Oblique", FontFamily -> " Times"], lpts[[#]], {1, 0}] & /@ Range[1, 2]; We can use these labels MultipleListPlot[data, PlotLabel->"My Plot", Epilog -> {fancy} ]; Regards, Dave.