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:
contour plot on patched object

Subject: contour plot on patched object

From: Yuyuan

Date: 18 Jan, 2010 17:15:22

Message: 1 of 4

I have
x=[1, 2, 3, 4, 2, 3, 3, 3, 2, 1];
y=[1, 0, 0, 1, 1.5, 1.5, 2, 3, 3, 2];
v=1:10;
h=patch(x,y,v);
How to add an contour plot onto h?

Subject: contour plot on patched object

From: Rob Campbell

Date: 18 Jan, 2010 19:27:04

Message: 2 of 4

"Yuyuan" <guyuyuan@hotmail.com> wrote in message <hj24va$psl$1@fred.mathworks.com>...
> I have
> x=[1, 2, 3, 4, 2, 3, 3, 3, 2, 1];
> y=[1, 0, 0, 1, 1.5, 1.5, 2, 3, 3, 2];
> v=1:10;
> h=patch(x,y,v);
> How to add an contour plot onto h?

Normally one can do things like that by changing the 'cdata' property of the object (h, in your case). However, I'm not sure that patch objects work like that because in this case 'cdata' is a vector of values defining the color at each point along the edge.

Are you just trying to make a mask for a contour plot? In this case, would something like this work for you?

clf
contour(peaks,100)
axes('position',get(gca,'position'))
h=patch(x,y,v);
set(gca,'color','none')
set(h,'facecolor','w','edgecolor','w')
axis off

Subject: contour plot on patched object

From: Yuyuan

Date: 18 Jan, 2010 20:38:04

Message: 3 of 4

"Rob Campbell" <matlab@robertREMOVEcampbell.removethis.co.uk> wrote in message <hj2cm7$65t$1@fred.mathworks.com>...
> "Yuyuan" <guyuyuan@hotmail.com> wrote in message <hj24va$psl$1@fred.mathworks.com>...
> > I have
> > x=[1, 2, 3, 4, 2, 3, 3, 3, 2, 1];
> > y=[1, 0, 0, 1, 1.5, 1.5, 2, 3, 3, 2];
> > v=1:10;
> > h=patch(x,y,v);
> > How to add an contour plot onto h?
>
> Normally one can do things like that by changing the 'cdata' property of the object (h, in your case). However, I'm not sure that patch objects work like that because in this case 'cdata' is a vector of values defining the color at each point along the edge.
>
> Are you just trying to make a mask for a contour plot? In this case, would something like this work for you?
>
> clf
> contour(peaks,100)
> axes('position',get(gca,'position'))
> h=patch(x,y,v);
> set(gca,'color','none')
> set(h,'facecolor','w','edgecolor','w')
> axis off
Thanks for reply Rob!

Actually, what I am really interested is trying to interpolate the sparsely distributed data inside an unit circle. I used TriScatteredInterp to construct an interpolant for the unit circle but it gave me NaNs outside the convahull by using 'linear' method, which generated a cracked cake. 'nearest' method won't give me NaNs but the interpolated surface looked so unnatural and unacceptable. So I am trying to directly patch (visualize) the data but it does not allow me to add contour onto the patched object. I am not sure if patch object is an assembly of many small triangle objects while contour is only good for surfaced (or metrics) objects?
Yuyuan

Subject: contour plot on patched object

From: ArtS

Date: 13 Sep, 2010 09:55:05

Message: 4 of 4

"Yuyuan" <guyuyuan@hotmail.com> wrote in message <hj2grc$go$1@fred.mathworks.com>...
> "Rob Campbell" <matlab@robertREMOVEcampbell.removethis.co.uk> wrote in message <hj2cm7$65t$1@fred.mathworks.com>...
> > "Yuyuan" <guyuyuan@hotmail.com> wrote in message <hj24va$psl$1@fred.mathworks.com>...
> > > I have
> > > x=[1, 2, 3, 4, 2, 3, 3, 3, 2, 1];
> > > y=[1, 0, 0, 1, 1.5, 1.5, 2, 3, 3, 2];
> > > v=1:10;
> > > h=patch(x,y,v);
> > > How to add an contour plot onto h?
> >
> > Normally one can do things like that by changing the 'cdata' property of the object (h, in your case). However, I'm not sure that patch objects work like that because in this case 'cdata' is a vector of values defining the color at each point along the edge.
> >
> > Are you just trying to make a mask for a contour plot? In this case, would something like this work for you?
> >
> > clf
> > contour(peaks,100)
> > axes('position',get(gca,'position'))
> > h=patch(x,y,v);
> > set(gca,'color','none')
> > set(h,'facecolor','w','edgecolor','w')
> > axis off
> Thanks for reply Rob!
>
> Actually, what I am really interested is trying to interpolate the sparsely distributed data inside an unit circle. I used TriScatteredInterp to construct an interpolant for the unit circle but it gave me NaNs outside the convahull by using 'linear' method, which generated a cracked cake. 'nearest' method won't give me NaNs but the interpolated surface looked so unnatural and unacceptable. So I am trying to directly patch (visualize) the data but it does not allow me to add contour onto the patched object. I am not sure if patch object is an assembly of many small triangle objects while contour is only good for surfaced (or metrics) objects?
> Yuyuan

Hello,

I have exactly the same problem:
I have some values for discrete vertices on a 3D patch object. Is it possible to interpolate the values for all the other vertices along the patch object?
Like Yuyuan said TriScatteredInterp returns NaNs for vertices outside the convex hull. Moreover it doesn't use the geometry information of the patch.
Maybe anyone knows a workaround by now?

Cheers

ArtS

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