MathGroup Archive 2007

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

Search the Archive

Re: Plot without Show

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79148] Re: Plot without Show
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 20 Jul 2007 03:13:44 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <f7n3tc$1g3$1@smc.vnet.net>

kitsche wrote:
> Hello,
> I often plot several functions with Plot or its siblings and at the end want to show a combined graph with all plots on it.
> p1 = Plot[Sin[x],{x,0,Pi}];
> p2 = Plot[Cos[x],{x,0,Pi}];
> Show[p1,p2];
> 
> The output from the above are 3 plots, p1, p2 and the combined. How can I plot p1 and p2 silently, ie. without that their plot shows and only show the combined form?
> 
> Thanks Karl

Hi Karl,

With versions prior Mathematica 6.0, you have to switch off temporary 
the default display function. For instance,

In[1]:=
p1 = Plot[Sin[x], {x, 0, Pi}, DisplayFunction ->
      Identity];
p2 = Plot[Cos[x], {x, 0, Pi}, DisplayFunction ->
      Identity];
Show[p1, p2, DisplayFunction -> $DisplayFunction];

In[4]:=
Block[{$DisplayFunction = Identity},
   p1 = Plot[Sin[x], {x, 0, Pi}];
   p2 = Plot[Cos[x], {x, 0, Pi}]; ]
Show[p1, p2];

The function *DisplayTogether* might be of interest too.

In[6]:=
<< "Graphics`"
DisplayTogether[p1, p2];

With version 6.0 and above, a semi-colon at the end of each plot command 
is enough.

p1 = Plot[Sin[x], {x, 0, Pi}];
p2 = Plot[Cos[x], {x, 0, Pi}];
Show[p1, p2]

(Note that there is no semi-colon after the *Show* command, otherwise it 
would prevent the display of graphics.)

Regards,
Jean-Marc


  • Prev by Date: Wolfram Workbench 1.1 now available
  • Next by Date: Re: strange bug?
  • Previous by thread: Re: Plot without Show
  • Next by thread: Re: Plot without Show