|
[Date Index]
[Thread Index]
[Author Index]
Tool for creating plot legends
- To: mathgroup at smc.vnet.net
- Subject: [mg124902] Tool for creating plot legends
- From: Chris Young <cy56 at comcast.net>
- Date: Sat, 11 Feb 2012 06:38:38 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
This will handle the general case of combined plots and let you
substitute in different function lists and colors, as well as move the
legend around and changing the spacings in the legend. Shouldn't be too
hard to adapt it to more general styles for the plotting and legend.
The Legend package won't automatically pick up the styles from the plot
except in the case where there's only one kind of plot. So in this
case, one should enter all the style definitions into a variable to be
shared by the plots and by the Legend.
http://home.comcast.net/~cy56/Mma/LegendTool.nb
http://home.comcast.net/~cy56/Mma/LegendToolPic.png
Chris Young
cy56 at comcast.net
DynamicModule[
{
graphic, (* for the graphics in the legend *)
colors = {Red, Yellow, Green},
fncs = {Sin, Cos, Log},
plotNames = {"sine", "cosine", "log"}
},
graphic[c_] := Graphics[{
c,
Line[{{-1, 0}, {1, 0}}],
PointSize[Medium], Point[{0, 0}]
}];
Manipulate[
ShowLegend[
Show[
Plot[
Table[f[x], {f, fncs}] // Evaluate,
{x, 0, 10},
PlotStyle -> colors
],
ListPlot[
Table[
{x, f[x]}, {f, fncs},
{x, 0, 10, 0.5}
],
PlotStyle -> colors,
PlotMarkers -> Graphics[{PointSize[Medium], Point[{0, 0}]}]
],
PlotRange -> {{0, 10}, {-2, 2}},
AspectRatio -> 4/10
],
{
Table[{graphic[colors[[i]]], plotNames[[i]]}, {i, 3}],
LegendPosition -> {1.1, -.4},
LegendSize -> {xLnth, yLnth},
ShadowBackground -> LightGray,
LegendSpacing -> spacing,
LegendTextOffset -> {textOffX, textOffY},
LegendTextSpace -> textSp,
LegendLabelSpace -> labelSp,
LegendBorderSpace -> borderSp
}
],
{{xLnth, 0.75}, 0, 2, 0.25},
{{yLnth, 0.5}, 0, 2, 0.25},
{{spacing, 0}, -2, 2, 0.25},
{{textOffX, 0}, -1, 1, 0.25},
{{textOffY, -0.25}, -1, 1, 0.25},
{{textSp, 0.5}, -1, 2, 0.25},
{{labelSp, 0}, -1, 2, 0.25},
{{borderSp, 0.5}, 0, 2, 0.25}
]
]
Prev by Date:
Shouldn't DurbinWatsonD be an options of NonlinearModelFit?
Next by Date:
Re: Baffled by FindMinimum
Previous by thread:
Shouldn't DurbinWatsonD be an options of NonlinearModelFit?
Next by thread:
Re: Locator-set Bezier curves mapped to 3D surface
|