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:
4D contour plot

Subject: 4D contour plot

From: edward kabanyas

Date: 6 Apr, 2012 06:05:17

Message: 1 of 8

Hi All,

I have 3D (time-longitude-latitude) data and I want to plot it to 3D plot. I read the contour3 in which it is contour3(X,Y,Z). However, for my case, the contour3 will be:

contour3(lat, long, time, data), but it does not work. any other suggestion ? Thank you..

Edward

Subject: 4D contour plot

From: ImageAnalyst

Date: 6 Apr, 2012 12:02:43

Message: 2 of 8

On Apr 6, 2:05 am, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> Hi All,
>
> I have 3D (time-longitude-latitude) data and I want to plot it to 3D plot. I read the contour3 in which it is contour3(X,Y,Z). However, for my case, the contour3 will be:
>
> contour3(lat, long, time, data), but it does not work. any other suggestion ? Thank you..
>
> Edward

------------------------------------------------------------------
Edward:
contour3 only plots 2D data (x, y, value) in a 2.5D (3D-like)
perspective picture. It does not plot 3D data, where you have 3
independent dimensions (x,y,z) and then a value associated with it,
like you have. To do that you'd have to do true 3D volume
visualization like programs like Avizo (http://www.vsg3d.com/avizo/
overview) do.

or (with a huge step down in functionality) look at something where
the 3rd dimension is color, like this:
http://www.mathworks.com/matlabcentral/fileexchange/9519-color-coded-3d-scatterplot

Subject: 4D contour plot

From: edward kabanyas

Date: 7 Apr, 2012 02:00:41

Message: 3 of 8

Dear ImageAnalysit;

Thanks for the suggestion..the following is my simple code:

Ddata, % size 176 x454x351 (176 latitude grid, 454 longtidu grid, 351 hour);

lat = -19.8: 0.2: 70; lat=lat(25:200);
lon = 70.2 :0.2:160; lon=lon(1:450);
 
time1=squeeze(Ddata(1,1:4,:))';

yrb =time1(:,1); month1b =time1(:,2); dayb =time1(:,3); hrb =time1(:,4);

for xx=1:1: length(time1)
DateNumberbG(xx) = datenum(yrb(xx),month1b(xx), dayb(xx), hrb(xx),0,0);
end

datap=Ddata(:,5:end,:);

Try to plot directly by scatter3 as
scatter3(lon,lat,DateNumberbG,datap,'filled');

is impossible, because we need to define color..probably as your suggestion, I need to use other software because matlab can not do it..

Again, thanks..

edward


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <d9696895-b07d-487a-b2fb-c491a1c8cda4@k4g2000yqa.googlegroups.com>...
> On Apr 6, 2:05 am, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> > Hi All,
> >
> > I have 3D (time-longitude-latitude) data and I want to plot it to 3D plot. I read the contour3 in which it is contour3(X,Y,Z). However, for my case, the contour3 will be:
> >
> > contour3(lat, long, time, data), but it does not work. any other suggestion ? Thank you..
> >
> > Edward
>
> ------------------------------------------------------------------
> Edward:
> contour3 only plots 2D data (x, y, value) in a 2.5D (3D-like)
> perspective picture. It does not plot 3D data, where you have 3
> independent dimensions (x,y,z) and then a value associated with it,
> like you have. To do that you'd have to do true 3D volume
> visualization like programs like Avizo (http://www.vsg3d.com/avizo/
> overview) do.
>
> or (with a huge step down in functionality) look at something where
> the 3rd dimension is color, like this:
> http://www.mathworks.com/matlabcentral/fileexchange/9519-color-coded-3d-scatterplot

Subject: 4D contour plot

From: ImageAnalyst

Date: 7 Apr, 2012 03:55:11

Message: 4 of 8

But scatter3() takes both size and color as inputs for the data point
markers. Won't that work for you?

Subject: 4D contour plot

From: edward kabanyas

Date: 7 Apr, 2012 04:45:28

Message: 5 of 8


> But scatter3() takes both size and color as inputs for the data point
> markers. Won't that work for you?

I got the following error:

??? Error using ==> scatter3 at 70
X, Y and Z must be vectors of the same length.

Error in ==> test3Darray at 26
scatter3(lon,lat,DateNumberbG,datap,'filled');
 
size of plotted data:
lon = 1 x 450
lat = 1 x 176
DateNumberbG = 1 x 351

datap = 176 x 450 x 351 ...

probably you could suggest the solution of the error..

thank you

Edward

Subject: 4D contour plot

From: ImageAnalyst

Date: 7 Apr, 2012 14:54:07

Message: 6 of 8

Edward, this is a scatter plot. So every point that is plotted must
have an X, a Y, a Z, a color, and a size. You have 450 lons but only
176 lats. How can you have a point with a lon but not a lat?????

Subject: 4D contour plot

From: Steven_Lord

Date: 9 Apr, 2012 14:52:00

Message: 7 of 8



"edward kabanyas" <djuky_hmi@yahoo.com> wrote in message
news:jlogp8$4io$1@newscl01ah.mathworks.com...
>
>> But scatter3() takes both size and color as inputs for the data point
>> markers. Won't that work for you?
>
> I got the following error:
>
> ??? Error using ==> scatter3 at 70
> X, Y and Z must be vectors of the same length.
>
> Error in ==> test3Darray at 26
> scatter3(lon,lat,DateNumberbG,datap,'filled');
>
> size of plotted data:
> lon = 1 x 450
> lat = 1 x 176
> DateNumberbG = 1 x 351
>
> datap = 176 x 450 x 351 ...
>
> probably you could suggest the solution of the error..

Use MESHGRID or NDGRID to create 176-by-450-by-351 arrays containing
longitude, latitude, and number for each point, then:

scatter3(lonArray(:), latArray(:), DateNumberbGArray(:), datap(:))

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

Subject: 4D contour plot

From: Kelly Kearney

Date: 9 Apr, 2012 17:40:12

Message: 8 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <d9696895-b07d-487a-b2fb-c491a1c8cda4@k4g2000yqa.googlegroups.com>...
> On Apr 6, 2:05 am, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> > Hi All,
> >
> > I have 3D (time-longitude-latitude) data and I want to plot it to 3D plot. I read the contour3 in which it is contour3(X,Y,Z). However, for my case, the contour3 will be:
> >
> > contour3(lat, long, time, data), but it does not work. any other suggestion ? Thank you..
> >
> > Edward
>
> ------------------------------------------------------------------
> Edward:
> contour3 only plots 2D data (x, y, value) in a 2.5D (3D-like)
> perspective picture. It does not plot 3D data, where you have 3
> independent dimensions (x,y,z) and then a value associated with it,
> like you have. To do that you'd have to do true 3D volume
> visualization like programs like Avizo (http://www.vsg3d.com/avizo/
> overview) do.
>
> or (with a huge step down in functionality) look at something where
> the 3rd dimension is color, like this:
> http://www.mathworks.com/matlabcentral/fileexchange/9519-color-coded-3d-scatterplot


Alternatively, you might want to take a look at the isosurface function. Coupled with patch, this might create the 3D contour effect you're looking for.

-Kelly

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