Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Combining plots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg48658] Re: Combining plots
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Wed, 9 Jun 2004 04:17:46 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 6/8/04 at 12:48 AM, vdmeer at science.uva.nl (Johan) wrote:


>Suppose I wish to show a combined plot, for instance
>
>a:=ListPlot[{1,2,3}]
>b:=ListPlot[{4,5,5}]

>using Show[a,b]
>
>Now Mathematica draws 3 graphics, one of a, b and one of a and b
>combined. I want to only see the third combined graph and not the
>first two graphs. Is that possible?

Yes.

>I tried something with setting DisplayFunction to Identity in a and
>b, but then Show doesn't show anything...

There are a number of ways roughly equivalent ways to achieve what you want. What you attempted is almost what you need. That is:

a = ListPlot[{1,2,3}, DisplayFunction->Identity];
b = ListPlot[{4,5,6}, DisplayFunction->Identity];
Show[a,b, DisplayFunction->$DisplayFunction];

Will do the trick.

As an aside, note I've used Set rather than DelayedSet. Set causes results of ListPlot to be immediately assigned to the variables. DelayedSet delays the evaluation of ListPlot until the variable is used later in Show. In this particular case, the difference should be unimportant. But if instead of ListPlot you were evaluating a complex integral and using that result in a loop, the difference could be quite significant. You probably would not want Mathematica to repeatedly evaluate the same integral in a loop which is what would occur with DelayedSet. 

You can achieve the same effect by putting the two ListPlot commands inside a Block construct that sets the local value of $DisplayFunction to Identity. Perphaps even easier would be to use DisplayTogether in the Graphics`Graphics` package, i.e.,

<<Graphics`
DisplayTogether[
    ListPlot[{1,2,3}],
    ListPlot[{4,5,6}]];


Essentially, DisplayTogether does the same trick of setting $DisplayFunction to Identity locally for you rather than having to specifically set up the Block construct I described.
--
To reply via email subtract one hundred and four


  • Prev by Date: RE: Combining plots
  • Next by Date: Re: Fwd: Re: what actually is in the WRI "functions" database?
  • Previous by thread: RE: Combining plots
  • Next by thread: Re: Combining plots