Re: Error List Plot with Legends
- To: mathgroup at smc.vnet.net
- Subject: [mg107679] Re: [mg107654] Error List Plot with Legends
- From: "David Park" <djmpark at comcast.net>
- Date: Mon, 22 Feb 2010 19:04:20 -0500 (EST)
- References: <3834717.1266826984649.JavaMail.root@n11>
With the Presentations package I would do it this way: Needs["Presentations`Master`"] Needs["ErrorBarPlots`"] ShowLegend[ Draw2D[ {Black, ErrorListPlot[Table[{i, RandomReal[0.5]}, {i, 10}], Joined -> True] // DrawGraphics, Red, ErrorListPlot[Table[{i + 3, RandomReal[0.5]}, {i, 10}], Joined -> True] // DrawGraphics}, AspectRatio -> 1/GoldenRatio, Axes -> True, ImageSize -> 400], {{{Black, "A"}, {Red, "B"}}, LegendPosition -> {0.4, -0.4}, LegendSize -> {0.3, 0.2}, LegendTextOffset -> {-2, 0}, LegendSpacing -> 0.6}, BaseStyle -> {FontSize -> 12, FontWeight -> "Bold"}] Legends are something of an old fashioned graphic technology. Their demerit is that they present a second rather prominent graphic that competes with the main data plot. Also, it is indirect and the eye has to go back and forth between the legend and the plot. A better method may sometimes be to directly label the curves with Text statements. However, a static printed plot of many closely twining curves may require a legend. The PlotLegends commands seem to have a logic to them but, for me at least, they seem overly complicated. Another method is to simple draw a much simpler, less obtrusive and more easily controlled legend directly on the plot. Draw2D[ {Black, ErrorListPlot[Table[{i, RandomReal[0.5]}, {i, 10}], Joined -> True] // DrawGraphics, Aliasing at Line[{Scaled[{.8, .2}], Scaled[{.9, .2}]}], Text["A", Scaled[{.92, .2}], {-1, 0}], Red, ErrorListPlot[Table[{i + 3, RandomReal[0.5]}, {i, 10}], Joined -> True] // DrawGraphics, Aliasing at Line[{Scaled[{.8, .15}], Scaled[{.9, .15}]}], Black, Text["B", Scaled[{.92, .15}], {-1, 0}]}, AspectRatio -> 1/GoldenRatio, Axes -> True, ImageSize -> 400] The aliasing was put back in so we don't get fuzzy horizontal lines. If you can work and display entirely in an active dynamic Mathematica notebook then there are much better solutions. First, you could use tooltips on the curves to identify them. Another method is to use a dynamic presentation in which one curve is shown in black or a bold color and all the other curves are shown very faintly. The viewer could select the curve to emphasize, say by a radio button bar. Or the display of each curve could be controlled by a checkbox. The viewer could choose to display whatever combination of curves he wanted to see at a time. Clicking the checkbox on and off would help identify the curve and the curve color could be built into the checkbox label. This way, a complex graphic can be simplified to multiple custom plots at the viewer's discretion. If one can manage it, dynamic graphics are far superior to static graphics. David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Ramiro [mailto:ramiro.barrantes at gmail.com] Any suggestions on how to add a legend in an ErrorBarPlot? The simple PlotLegend option that used to work on ListPlot doesn't work here. Needs["ErrorBarPlots`"]; Needs["PlotLegends`"]; ListPlot[{Table[i, {i, 10}], Table[i + 3, {i, 10}]}, Joined -> True, PlotLegend -> {"A", "B"}] ErrorListPlot[{Table[{i, RandomReal[0.5]}, {i, 10}], Table[{i + 3, RandomReal[0.5]}, {i, 10}]}, Joined -> True, PlotLegend -> {"A", "B"}]