RE: Using legend with FilledPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg74433] RE: [mg74393] Using legend with FilledPlot
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Wed, 21 Mar 2007 02:49:39 -0500 (EST)
- References: <200703200305.WAA14968@smc.vnet.net>
Hi Michelasso > Ok, I have tried to answer to myself to the previous > questions I made, and I have almost managed to get what I > want, except for one thing: I cannot put legend into grpahics > I draw with FilledPlot funtion. > For example this works: > Plot[{Sin[x], Cos[x]}, {x, -3, 3}, PlotStyle -> {Hue[0.4], Hue[0.6]}, > PlotLegend -> {"a", "b"}, LegendTextSpace -> 10, > LegendShadow -> None, LegendPosition -> {0.2, -0.3}, > LegendSize -> {0.9, 0.2}] > > but if I replace Plot with FilledPlot I don't have anymore a legend. > Is there any way to obtain a legend with FilledPlot? Yes there is, but you'll have to work a bit harder and construct your own. It's tedious, but straightforward. First, you'll need to construct the lines that will go into your legend. lin = {{Blue, Line[{{-1, 0}, {0, 0}}]}, {Green, Line[{{-1, 0}, {0, 0}}]}}; lin = Graphics[#] & /@ lin; Next, make the legend lgd = {Transpose[{lin, {"a", "b"}}], LegendTextSpace -> 10, LegendShadow -> None, LegendPosition -> {0.2, -0.3}, LegendSize -> {0.9, 0.2} }; Finally, put it all together. FilledPlot[{Sin[x], Cos[x]}, {x, -3, 3}, PlotStyle -> {Blue, Green}, FrameTicks -> {PiScale, Automatic, None, None}, DisplayFunction -> Identity]; ShowLegend[%, lgd]; Tedious, as I said, but straightforward. There is a school of thought that says you're better off not using legends since they detract from the information. For more, see any of the books by Tufte. Regards, Dave.
- References:
- Using legend with FilledPlot
- From: Michelasso <qzerty@gmail.com>
- Using legend with FilledPlot