[Date Index]
[Thread Index]
[Author Index]
Re: Making nice-looking Legend for Plot
*To*: mathgroup at smc.vnet.net
*Subject*: [mg89731] Re: Making nice-looking Legend for Plot
*From*: lehin.p at gmail.com
*Date*: Thu, 19 Jun 2008 05:43:12 -0400 (EDT)
*References*: <g35g09$9bm$1@smc.vnet.net> <g37f0v$pts$1@smc.vnet.net>
On 17 June, 08:36, "David Park" <djmp... at comcast.net> wrote:
> In your particular case, with only two curves, why use a legend at all? W=
hy
> not just directly label the curves as follows?
>
> Plot[{100/x, x/1000 + 1}, {x, 100, 433},
> Epilog -> {Text["NMA", {196.056, 0.587105}],
> Text["DMA", {183.881, 1.27148}]},
> AspectRatio -> 1/2,
> Frame -> True, Axes -> False,
> FrameLabel -> {x, "curves"},
> PlotRange -> {0, 1.5},
> PlotLabel -> Style["NMA and DMA Curves", 12],
> ImageSize -> 400]
>
> I always find the PlotLegend package difficult to use. It is hard to obta=
in
> precise control. So if one must have a legend it is easier to construct i=
t
> by hand. The advantage is that you know exactly what is happening. Here i=
s
> how I would do it with the Presentations package:
>
> Needs["Presentations`Master`"]
>
> With[
> {location = {.75, .4},
> legendsize = {.20, .25},
> shadowoffset = {.02, -.03},
> laboffset = .04,
> lineoffset = .1,
> linelength = .08,
> lab1yoffset = .17,
> lab2yoffset = .06},
> Draw2D[
> {(* Legend Frame *)
> Rectangle[Scaled[location + shadowoffset],
> Scaled[location + legendsize + shadowoffset]],
> White,
> Rectangle[Scaled[location], Scaled[location + legendsize]],
>
> (* NMA curve *)
> Blend[{Blue, Black}, .5],
> Draw[100/x, {x, 100, 433}],
> Text["NMA", Scaled[location + {laboffset, lab1yoffset}]],
> Line[{Scaled[location + {lineoffset, lab1yoffset}],
> Scaled[location + {lineoffset + linelength, lab1yoffset}]}],
> Blend[{Red, Black}, .5],
>
> (* DMA curve *)
> Draw[x/1000 + 1, {x, 100, 433}],
> Text["DMA", Scaled[location + {laboffset, lab2yoffset}]],
> Line[{Scaled[location + {lineoffset, lab2yoffset}],
> Scaled[location + {lineoffset + linelength, lab2yoffset}]}]},
>
> AspectRatio -> 1/2,
> Frame -> True,
> FrameLabel -> {x, "curves"},
> PlotLabel -> Style["NMA and DMA Curves", 12],
> ImageSize -> 400]
> ]
>
> Legends generally are not good devices even though they are often used.
> Basically they are just another 'plot' that detracts from the main plot.
> That's why it is much better to directly label the curves if you can. Why
> label curves indirectly when you can label them directly? The one place
> where a legend might be useful is for contour or density plots. And there=
it
> is better to construct your own. And the contour line tooltips on
> Mathematica contour plots are better than any legend. So throw the Legend
> package into the trash can and save yourself a lot of grief.
>
> If there are many intertwined curves then it may be impossible to directl=
y
> label them in a useful manner. That would seem to call for a legend. But =
how
> does a legend really help there? The main problem is to be able to pick o=
ut
> each curve and yet show it in relation to the other curves. I have an
> example in the Presentations package that shows a method for doing this. =
It
> uses a TabView for multiple graphics and each graphic shows one curve and
> its data points with the other curves in a fainter subdued representation=
Prev by Date:
**Re: Re: snippets**
Next by Date:
**Re: Workbench editing snag**
Previous by thread:
**Re: Making nice-looking Legend for Plot**
Next by thread:
**Re: Making nice-looking Legend for Plot**
| |