Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: Combining ContourPlot and Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64569] Re: Combining ContourPlot and Plot
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Thu, 23 Feb 2006 00:34:04 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 2/22/06 at 5:58 AM, dkjk at bigpond.net.au wrote:

>The title says it all really. I want something like

>Show[Plot[x,{x,-1,1}],ContourPlot[x^2+y^2,{x,-1,1},{y,-1,1}]]

>I've looked through the usenet archive to no avail.

Is this what you want?

Show[
    Block[{$DisplayFunction = Identity},
      {ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}], 
      Plot[x, {x, -1, 1}]}]];

I've done two things differently. First, I've used Block to temporarily set $DisplayFunction to Identity, suppressing display of the individual plots. Second, I've reversed the order in which the plots are made.

Several of the default options for ContourPlot conflict with the defaults for Plot. When the graphics are combined, the first value of an option determines the way the combined graphics appears.

For example,

Plot[x,{x,-1,1},AspectRatio->1,AspectRatio->1/GoldenRule];

plots with an aspect ratio of 1.

Also, given the large dark area in the contour plot, I think the following combination is more visually informative

Show[
    Block[{$DisplayFunction = Identity},
      {ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}, 
      ContourShading -> False], 
      Plot[x, {x, -1, 1}, PlotStyle -> Red]}]];
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Can't multiply non-square matrices.
  • Next by Date: Re: Checking function syntax
  • Previous by thread: Re: Combining ContourPlot and Plot
  • Next by thread: Increment and AddTo