Got Questions? Get Answers.
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:
Overlaying plots with different axes

Subject: Overlaying plots with different axes

From: David

Date: 7 Mar, 2012 13:04:24

Message: 1 of 3

Hi,

I am trying to overlay a contour plot on top of a pcolor plot; the pcolor plot is 6x9 whereas the contour plot is 60x90.
This means when I overlay using 'hold', the pcolor plot ends up being very small in the corner of the contour plot or vice versa.

Is there any way of overlaying the two plots without changing their size?

Thanks for any help,
Dave

Subject: Overlaying plots with different axes

From: Steven_Lord

Date: 7 Mar, 2012 14:27:59

Message: 2 of 3



"David " <sum_is_41@hotmail.com> wrote in message
news:jj7mco$3rf$1@newscl01ah.mathworks.com...
> Hi,
>
> I am trying to overlay a contour plot on top of a pcolor plot; the pcolor
> plot is 6x9 whereas the contour plot is 60x90.
> This means when I overlay using 'hold', the pcolor plot ends up being very
> small in the corner of the contour plot or vice versa.
>
> Is there any way of overlaying the two plots without changing their size?

Call PCOLOR with three inputs and call CONTOUR with one of these syntaxes:

contour(X,Y,Z)
contour(X,Y,Z,n)
contour(X,Y,Z,v)

You'll need to generate X and Y vectors or matrices such that both plots
cover the same range of your axes.

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

Subject: Overlaying plots with different axes

From: David

Date: 7 Mar, 2012 17:29:17

Message: 3 of 3

"Steven_Lord" <slord@mathworks.com> wrote in message <jj7r9g$ko8$1@newscl01ah.mathworks.com>...
>
>
> "David " <sum_is_41@hotmail.com> wrote in message
> news:jj7mco$3rf$1@newscl01ah.mathworks.com...
> > Hi,
> >
> > I am trying to overlay a contour plot on top of a pcolor plot; the pcolor
> > plot is 6x9 whereas the contour plot is 60x90.
> > This means when I overlay using 'hold', the pcolor plot ends up being very
> > small in the corner of the contour plot or vice versa.
> >
> > Is there any way of overlaying the two plots without changing their size?
>
> Call PCOLOR with three inputs and call CONTOUR with one of these syntaxes:
>
> contour(X,Y,Z)
> contour(X,Y,Z,n)
> contour(X,Y,Z,v)
>
> You'll need to generate X and Y vectors or matrices such that both plots
> cover the same range of your axes.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Thanks for taking the time to help, I managed to work out a way of doing it.
The code I used is below:

pcolor(s(:,:,1));
h1=gca;
h2=axes('position',get(h1,'position'));
contour(x)
set(h2,'YAxisLocation','right','Color','none','XTickLabel',[])

Cheers,
Dave

Tags for this Thread

No tags are associated with 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