Re: A nice and customized legend within Manipulate
- To: mathgroup at smc.vnet.net
- Subject: [mg128576] Re: A nice and customized legend within Manipulate
- From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
- Date: Mon, 5 Nov 2012 18:40:01 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
Hello
I need to create a cdf document as a standalone file that can be used in
a computer without Mathematica. There is quite a few plots in the doc
and I need to add nice legends to it. At first I tried the Legend
package but I found the result awful and worse than that it breaks the
standalone cdf (something to do with Needs and Get or the like).
It seems that I need to add a initialization code within Manipulate but
I have no idea on how to do it. Could someone help me with an example,
please?
Finally, is there a simple way to create nice legends? I saw several
posts on the web but could not gather much from them. A nice and simple
example (for a newbie) will help me a lot.
Many thanks
Ed
Hi, Ed,
Try this:
Plot[{x, x^2}, {x, -10, 10}, PlotRange -> All,
PlotStyle -> {Blue, Red},
(* Here the legend starts*)
Epilog ->
Inset[Grid[{{Graphics[{Blue, Line[{{0, 0}, {1, 0}}]},
ImageSize -> {20, 20}],
Style["First line",
14]}, {Graphics[{Red, Line[{{0, 0}, {1, 0}}]},
ImageSize -> {20, 20}], Style["Second line", 14]}},
Alignment -> {Left, Center}, Spacings -> 0], {5, 80}]
(* The end of the legend *)
]
and this:
(* These are two lists to plot *)
lst1 = Table[{x, x}, {x, -10, 10, 0.5}];
lst2 = Table[{x, x^2}, {x, -10, 10, 0.5}];
(* End of lists definition *)
ListPlot[{lst1, lst2}, PlotRange -> All, PlotStyle -> {Blue, Red},
(* Here the legend starts*)
Epilog ->
Inset[Panel[
Grid[{{Graphics[{Blue, Point[{0, 0}]}, ImageSize -> {20, 20}],
Style["First list", 14]}, {Graphics[{Red, Point[{0, 0}]},
ImageSize -> {20, 20}], Style["Second list", 14]}},
Alignment -> {Left, Center}, Spacings -> 0],
ImageSize -> {105, 80}], {4, 85}]
(* The end of the legend *)
]
Have fun, Alexei
Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG
Office phone : +352-2454-2566
Office fax: +352-2454-3566
mobile phone: +49 151 52 40 66 44
e-mail: alexei.boulbitch at iee.lu