MathGroup Archive 2011

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

Search the Archive

Re: PlotLegend and Show

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117951] Re: PlotLegend and Show
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 5 Apr 2011 06:44:51 -0400 (EDT)

Needs["PlotLegends`"]

p2 = Plot[{Sin[x + Pi], Cos[x + Pi]}, {x, 0, 2 Pi}];

Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi},
 PlotLegend -> {"sine", "cosine"},
 LegendSize -> {.5, .25},
 LegendShadow -> None,
 Epilog -> Transpose[{
    Cases[p2, Hue[__], Infinity],
    Cases[p2, Line[_], Infinity]}]]


Bob Hanlon

---- Robert McHugh <r62m10 at gmail.com> wrote: 

=============
Have made a plot which uses PlotLegend.  Would like to combine this plot
with another plot.  Tried using Show[] to do this, but the results were not
not what I expected.  In the combined plot, the second plot doesn't have the
same scale as the first plot. When I remove the PlotLegend option from the
first plot and use show to combine the two plots all is well.  Below is an
example. (Though in the case I would like to run, there are about 10
different graphs in the first plot, so making the legend by hand would be
time consuming.)

Recommendations? Thanks.

(* this isn't what I want *)
p1 = Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi},  PlotLegend -> {"sine", "cosine"}]
p2 = Plot[{Sin[x + \[Pi]], Cos[x + \[Pi]]}, {x, 0, 2 Pi}]
Show[p1, p2]

(* remove the legend and all is well *)
p1 = Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi} ]
p2 = Plot[{Sin[x + \[Pi]], Cos[x + \[Pi]]}, {x, 0, 2 Pi}]
Show[p1, p2]



  • Prev by Date: Re: Mathematica 8.01 and the CDF plug-in
  • Next by Date: Re: writing own package: cannot read it in..
  • Previous by thread: Re: PlotLegend and Show
  • Next by thread: Re: PlotLegend and Show