Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: A nice and customized legend within Manipulate
Replies: 1   Last Post: Nov 5, 2012 6:40 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alexei Boulbitch

Posts: 479
Registered: 2/28/08
Re: A nice and customized legend within Manipulate
Posted: Nov 5, 2012 6:40 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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@iee.lu







Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.