MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Legends for Data Plots: an addition to the previous post

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129963] Re: Legends for Data Plots: an addition to the previous post
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Thu, 28 Feb 2013 21:24:42 -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

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







  • Prev by Date: Re: World map as Texture
  • Next by Date: Re: World map as Texture
  • Previous by thread: Re: World map as Texture
  • Next by thread: Mathematica + ZEMAX