Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot3 - hold on - contour3, possible?!!

Subject: plot3 - hold on - contour3, possible?!!

From: Camille Couzi

Date: 14 Feb, 2012 15:04:48

Message: 1 of 2

Hello my matlab friends!

I am trying to use plot3 and contour3 in the same figure, overlying them by using hold on. is it possible?
I don't know why, when I run my script where first is defined plot3, and then contour3, I can see my plot3, but the contour3 doesn't appear. Matlab doesn't crash or send me any error, so I imagine it's working, but I can't understant why i don't see the contour3.

If it was a problem of differences in values of the x and y axis, I could see both graphs, right? (I say that, but my X and Y in the polar3 an contour3 are the same...).

Strange! Has anybody a clue of what is happening?!
thanks in advance!!

Subject: plot3 - hold on - contour3, possible?!!

From: Steven_Lord

Date: 14 Feb, 2012 17:29:33

Message: 2 of 2



"Camille Couzi" <cco@dhi.com.sg> wrote in message
news:jhdt6g$b5h$1@newscl01ah.mathworks.com...
> Hello my matlab friends!
>
> I am trying to use plot3 and contour3 in the same figure, overlying them
> by using hold on. is it possible?

I don't see why not.

> I don't know why, when I run my script where first is defined plot3, and
> then contour3, I can see my plot3, but the contour3 doesn't appear. Matlab
> doesn't crash or send me any error, so I imagine it's working, but I can't
> understant why i don't see the contour3.
> If it was a problem of differences in values of the x and y axis, I could
> see both graphs, right? (I say that, but my X and Y in the polar3 an
> contour3 are the same...).

I don't know what you mean by polar3, but I did put PLOT3 and CONTOUR3 plots
in the same axes, using a modified version of the example from CONTOUR.

[x, y, z] = peaks;
plot3(x, y, z);
hold on
contour3(x, y, z, [-1 1]);

Now if you'd done something like this:

[x, y, z] = peaks;
maxZ = max(z(:));
plot3(x, y, z);
hold on
contour3(x, y, z, [maxZ+1 maxZ+1]);

then I wouldn't expect to see any contours, as there's no data at height
maxZ+1 from which to create the contour plot.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us