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: Re: Legends for Data Plots: an addition to the previous post
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Alexei Boulbitch

Posts: 483
Registered: 2/28/08
Re: Legends for Data Plots: an addition to the previous post
Posted: Mar 2, 2013 2:34 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

....here all works, except the Legends entry for the data is a line and not a
Point...


... there is no simple way to make a common frame. Or at least I do not see such a way...

Hi, Kevin,

This is an addition to my earlier answer. Here is a way to have a common frame or panel around the two legends: one of which is PointLegend and the next is the LineLegend:

Here it is with a Panel:

lst = Transpose[{RandomReal[{0, 3}, 30],
RandomReal[{-0.03, 0.03}, 30]}] /. {x_, y_} -> {x, x*Exp[-x] + y};
ft = FindFit[lst, a + b*x*Exp[-c*x], {a, b, c}, x];

Show[{
ListPlot[lst, PlotRange -> {{0, 3.5}, Automatic}
],

Plot[a + b*x*Exp[-c*x] /. ft, {x, 0, 3},
PlotRange -> {{0, 3.5}, Automatic}, PlotStyle -> Red]
},

(* The legends are in the Epilog start here *)
Epilog -> Inset[Panel[Column[{
PointLegend[{Blue}, {" Data"}],
LineLegend[{Red}, \
{"f(x)=\!\(\*SuperscriptBox[\(x\[ExponentialE]\), \(-x\)]\)"}]
}]], Scaled[{0.8, 0.85}]]
(* End of the Legends*)

]

Here it is with the Frame:

lst = Transpose[{RandomReal[{0, 3}, 30],
RandomReal[{-0.03, 0.03}, 30]}] /. {x_, y_} -> {x, x*Exp[-x] + y};
ft = FindFit[lst, a + b*x*Exp[-c*x], {a, b, c}, x];

Show[{
ListPlot[lst, PlotRange -> {{0, 3.5}, Automatic}
],

Plot[a + b*x*Exp[-c*x] /. ft, {x, 0, 3},
PlotRange -> {{0, 3.5}, Automatic}, PlotStyle -> Red]
},

(* The legends are in the Epilog start here *)
Epilog -> Inset[Framed[Column[{
PointLegend[{Blue}, {" Data"}],
LineLegend[{Red}, \
{"f(x)=\!\(\*SuperscriptBox[\(x\[ExponentialE]\), \(-x\)]\)"}]
}], RoundingRadius -> 5], Scaled[{0.8, 0.85}]]
(* End of the Legends *)

]

Have fun.

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.