Thread Subject: Contour graph help!

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 14:59:02

Message: 1 of 22

I'm looking to make a contour graph with:
X-axis being dates (increasing to the right)
Y-axis being different lake water depth(increasing downward)
and Color from red to blue on the graph indicating various
temperatures with legend indicating which color is which
temperature.
This way you can find the temperature of the exact data and
water depth by comparing the color at that point with the
legend.
How do I do this in matlab? I tried contourf but couldn't
get it to work right. Any help?
I'm using matlab 5.3 right now, but any if the method is for
a newer version, it is welcome too since I might be able to
get a copy of the newest version.

Thanks

Subject: Contour graph help!

From: John D'Errico

Date: 2 Jul, 2008 15:29:02

Message: 2 of 22

"Zijia Li" <triplezzz21@gmail.com> wrote in message
<g4g53m$7mf$1@fred.mathworks.com>...
> I'm looking to make a contour graph with:
> X-axis being dates (increasing to the right)
> Y-axis being different lake water depth(increasing downward)
> and Color from red to blue on the graph indicating various
> temperatures with legend indicating which color is which
> temperature.
> This way you can find the temperature of the exact data and
> water depth by comparing the color at that point with the
> legend.
> How do I do this in matlab? I tried contourf but couldn't
> get it to work right. Any help?
> I'm using matlab 5.3 right now, but any if the method is for
> a newer version, it is welcome too since I might be able to
> get a copy of the newest version.
>
> Thanks

What did you try? What did not work? Contourf
is the correct tool for this purpose.

John

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 15:57:01

Message: 3 of 22

the problem is that the temperature matrix and the date/time
matrix is 9694x1, so it gives Index exceeds matrix dimensions.
How can I make it work?

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 16:03:03

Message: 4 of 22


> What did you try? What did not work? Contourf
> is the correct tool for this purpose.
>
> John
The problem is that the temperature and date/time matrix are
9694x1 so it is giving the error "index exceeds matrix
dimensions" when I use contourf.
any way to bypass this or some other way to do it?

Subject: Contour graph help!

From: hailiang shen

Date: 2 Jul, 2008 16:25:04

Message: 5 of 22

first generate the mesh with 'meshgrid' function, and then
use the 'contourf' to have the plot.

of course your z data have to be set the same size as the
mesh

Subject: Contour graph help!

From: John D'Errico

Date: 2 Jul, 2008 16:40:03

Message: 6 of 22

"Zijia Li" <triplezzz21@gmail.com> wrote in message
<g4g8rn$3bk$1@fred.mathworks.com>...
>
> > What did you try? What did not work? Contourf
> > is the correct tool for this purpose.
> >
> > John
> The problem is that the temperature and date/time matrix are
> 9694x1 so it is giving the error "index exceeds matrix
> dimensions" when I use contourf.
> any way to bypass this or some other way to do it?

You can't "bypass" it.

Your data is not in the form that contourf needs.
How is contourf to know what how you wish it
to interpret that vector of data? Do you have the
mindreading toolbox installed? (This is a new
one that they try to keep secret until they get
all the bugs out of it. The biggest problem is
the requirement that you install electric wires
directly into your brain. Few people seem to like
that idea.)

Seriously, what does this vector of length 9694
contain?

John

Subject: Contour graph help!

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 2 Jul, 2008 16:52:26

Message: 7 of 22

In article <g4gb13$rss$1@fred.mathworks.com>,
John D'Errico <woodchips@rochester.rr.com> wrote:

>Your data is not in the form that contourf needs.
>How is contourf to know what how you wish it
>to interpret that vector of data? Do you have the
>mindreading toolbox installed? (This is a new
>one that they try to keep secret until they get
>all the bugs out of it. The biggest problem is
>the requirement that you install electric wires
>directly into your brain. Few people seem to like
>that idea.)

They found different algorithms that don't need the
wires, and released it as the Hathor Toolbox (in
Alpha release, anyhow.) I hear that the full functionality
is delayed until they finish integrating it with
the SimBioFuels Toolkit to deal with the garbage collection
routines.
--
  "Whenever there is a hard job to be done I assign it to a lazy
  man; he is sure to find an easy way of doing it."
                                              -- Walter Chrysler

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 17:06:02

Message: 8 of 22

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g4gb13$rss$1@fred.mathworks.com>...

> You can't "bypass" it.
>
> Your data is not in the form that contourf needs.
> How is contourf to know what how you wish it
> to interpret that vector of data? Do you have the
> mindreading toolbox installed? (This is a new
> one that they try to keep secret until they get
> all the bugs out of it. The biggest problem is
> the requirement that you install electric wires
> directly into your brain. Few people seem to like
> that idea.)
>
> Seriously, what does this vector of length 9694
> contain?
>
> John

You are too funny! I wish I can grow up to be as funny as you.
But if you are not going to help me why bother posting a
respond.
As I stated on my previous post the matrix are Temperature
and date/time, so it is a list of Temperature and date/time
that I imported from txt files. It is a year worth of
temperature data of from Lake Michigan of different depth.
We are trying to examine of effects of global warming.

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 17:07:01

Message: 9 of 22


> They found different algorithms that don't need the
> wires, and released it as the Hathor Toolbox (in
> Alpha release, anyhow.) I hear that the full functionality
> is delayed until they finish integrating it with
> the SimBioFuels Toolkit to deal with the garbage collection
> routines.
> --
> "Whenever there is a hard job to be done I assign it to
a lazy
> man; he is sure to find an easy way of doing it."
> -- Walter
Chrysler

you too

Subject: Contour graph help!

From: John D'Errico

Date: 2 Jul, 2008 17:25:03

Message: 10 of 22

"Zijia Li" <triplezzz21@gmail.com> wrote in message
<g4gchq$hdn$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <g4gb13$rss$1@fred.mathworks.com>...
>
> > You can't "bypass" it.
> >
> > Your data is not in the form that contourf needs.
> > How is contourf to know what how you wish it
> > to interpret that vector of data? Do you have the
> > mindreading toolbox installed? (This is a new
> > one that they try to keep secret until they get
> > all the bugs out of it. The biggest problem is
> > the requirement that you install electric wires
> > directly into your brain. Few people seem to like
> > that idea.)
> >
> > Seriously, what does this vector of length 9694
> > contain?
> >
> > John
>
> You are too funny! I wish I can grow up to be as funny as you.
> But if you are not going to help me why bother posting a
> respond.

I AM helping you. But a vector is not obviously
an array of data in any specific form. You need
to explain what you have, else I'm just guessing.
And those wires on the mindreading thingy keep
shorting out on me. (It hurts like hell then.) On
the other hand, its just like electroshock therapy.
I've quit smoking, and I'm now down to only two
personalities. ;-)


> As I stated on my previous post the matrix are Temperature
> and date/time, so it is a list of Temperature and date/time
> that I imported from txt files. It is a year worth of
> temperature data of from Lake Michigan of different depth.
> We are trying to examine of effects of global warming.

Still not terribly clear. Why must I drag it out
of you?

Assuming that you have scattered data, then
you must use either griddata or my own gridfit
from the file exchange to convert it to a gridded
array. Then use contourf.

John

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 18:15:06

Message: 11 of 22

OK
I have matrix: dateTime(9694x1 list of date and time of each
time the sensor recorded the temperature), depth(11x1 all
the defferent depth the data was taken), surfaceTemp(9694x1
list of surface temperatures corresponding to the dateTime
matrix), temp5(9694x1 list of temperatures at 5m below water
surface corresponding to the dateTime matrix), temp10,
temp15, temp20, temp30, temp50, temp70, temp90, temp110,
temp140.

Thanks to hailiang shen. I did
"[x,y]=meshgrid(dateTime,depth)" to make the grid which
creates x(11x9694) and y(11x9694). Then I transposed all the
surfaceTemp-temp140 matrix becomes(1x9694). Then created a
temp matrix that contains all the temperature matrix(11x9694).
Then I did contourf(x,y,temp). This made a really weird
graph. The axis are correct with depth on the y-axis and
dateTime on the x-axis. But the temperature colors are werid
with mostly all dark blue with some red, orange, and stuff.
The legend has for some reason a list of "date0" through
"date63" corresponded with random colors(not continuous
change from blue to red, but 5 different colors spreas
randomly).
Was that clear? It's hard to explain how a graph looks like.
Any ideas?

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 18:42:01

Message: 12 of 22

This may be more clear
here is the M-file code:
load dateTime.txt
load depth.txt
load surfaceTemp.txt
load temp5.txt
load temp10.txt
load temp15.txt
load temp20.txt
load temp30.txt
load temp50.txt
load temp70.txt
load temp90.txt
load temp110.txt
load temp140.txt
[x,y]=meshgrid(dateTime,depth);
surfaceTemp=surfaceTemp.';
temp5=temp5.';
temp10=temp10.';
temp15=temp15.';
temp20=temp20.';
temp30=temp30.';
temp50=temp50.';
temp70=temp70.';
temp90=temp90.';
temp110=temp110.';
temp140=temp140.';
temp=[surfaceTemp;temp5;temp10;temp15;temp20;temp30;temp50;temp70;temp90;temp110;temp140];
contourf(x,y,temp)

Subject: Contour graph help!

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 2 Jul, 2008 18:44:40

Message: 13 of 22

In article <g4gchq$hdn$1@fred.mathworks.com>,
Zijia Li <triplezzz21@gmail.com> wrote:

>You are too funny! I wish I can grow up to be as funny as you.
>But if you are not going to help me why bother posting a
>respond.

A bit of humour helps keep us sane. It is unfortunately fairly
common for people to present incomplete requirements or
impossible requirements or requirements that we cannot figure
out the meaning of; if we don't laugh about it sometimes then
the frustration burns us out.
--
  "Do not wait for leaders. Do it alone, person to person."
                                              -- Mother Teresa

Subject: Contour graph help!

From: Zijia Li

Date: 2 Jul, 2008 19:50:19

Message: 14 of 22

Ok
So, I when I do contourf(x,y,temp,1000), it makes the graph
with 1000 colors, but it has a lot of black lines. So I did
contour(x,y,temp,2000). This makes the graph with 2000
colors(takes like half and hour to make), which looks really
good but the legend has 63 different color blocks with
data1-data63 labeled by it. I don't know where it got the 63
temperature labels from.
What I want is one bar of color transitioning from blue to
red labeled 0C on top by blue and 25C on the bottom by the red.

Can I do that on matlab? If so, how?

Subject: Contour graph help!

From: NZTideMan

Date: 2 Jul, 2008 20:16:43

Message: 15 of 22

On Jul 3, 7:50=A0am, "Zijia Li" <triplezz...@gmail.com> wrote:
> Ok
> So, I when I do contourf(x,y,temp,1000), it makes the graph
> with 1000 colors, but it has a lot of black lines. So I did
> contour(x,y,temp,2000). This makes the graph with 2000
> colors(takes like half and hour to make), which looks really
> good but the legend has 63 different color blocks with
> data1-data63 labeled by it. I don't know where it got the 63
> temperature labels from.
> What I want is one bar of color transitioning from blue to
> red labeled 0C on top by blue and 25C on the bottom by the red.
>
> Can I do that on matlab? If so, how?

This thread has been good fun....
Don't panic!! You're almost there.
Instead of imposing a large number of contours, start by trying just a
few - like 26 for example (i.e. 1 deg contour levels).
contourf(x,y,temp,26)
This will take less time. Then once you've got things working you can
increase the number of contour levels.

The reason you saw lots of black lines when you had 2000 contour
levels is that each contour is marked with a black line. You can turn
this off and have a smooth transition between colours by specifying:
shading interp

I think the 63 colour blocks come from the colormap you are using.
You can play with this and get exactly the range of colours you want.
Type help colormap to see the details of how to do it.

Subject: Contour graph help!

From: Zijia Li

Date: 3 Jul, 2008 13:30:04

Message: 16 of 22

NZTideMan <mulgor@gmail.com> wrote in message
<ca9f2103-0970-484d-afed-183e4be30104@w5g2000prd.googlegroups.com>...
> On Jul 3, 7:50=A0am, "Zijia Li" <triplezz...@gmail.com> wrote:
> > Ok
> > So, I when I do contourf(x,y,temp,1000), it makes the graph
> > with 1000 colors, but it has a lot of black lines. So I did
> > contour(x,y,temp,2000). This makes the graph with 2000
> > colors(takes like half and hour to make), which looks really
> > good but the legend has 63 different color blocks with
> > data1-data63 labeled by it. I don't know where it got the 63
> > temperature labels from.
> > What I want is one bar of color transitioning from blue to
> > red labeled 0C on top by blue and 25C on the bottom by
the red.
> >
> > Can I do that on matlab? If so, how?
>
> This thread has been good fun....
> Don't panic!! You're almost there.
> Instead of imposing a large number of contours, start by
trying just a
> few - like 26 for example (i.e. 1 deg contour levels).
> contourf(x,y,temp,26)
> This will take less time. Then once you've got things
working you can
> increase the number of contour levels.
>
> The reason you saw lots of black lines when you had 2000
contour
> levels is that each contour is marked with a black line.
You can turn
> this off and have a smooth transition between colours by
specifying:
> shading interp
>
> I think the 63 colour blocks come from the colormap you
are using.
> You can play with this and get exactly the range of
colours you want.
> Type help colormap to see the details of how to do it.

Thanks
But "Shading interp" gives me "warning:color data is not set
for interpolated shading" and it doesn't graph anything(the
graph is blank)
Any help?

Subject: Contour graph help!

From: Zijia Li

Date: 3 Jul, 2008 14:55:07

Message: 17 of 22

I found the "colorbar" function which makes the color bar I
wanted. The graph for now I put it on "shading flat" because
"shading interp" still doesn't work.

Subject: Contour graph help!

From: Zijia Li

Date: 3 Jul, 2008 17:58:02

Message: 18 of 22

so, no one knows why it's giving that error message?

Subject: Contour graph help!

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 3 Jul, 2008 18:11:34

Message: 19 of 22

In article <g4j3va$8ba$1@fred.mathworks.com>,
Zijia Li <triplezzz21@gmail.com> wrote:
>so, no one knows why it's giving that error message?

You are probably referring to the error message you mentioned earlier
in the thread when you turned on shading interp,
"warning:color data is not set for interpolated shading"

The reason it is giving you that error is that ... you haven't
set the color data needed for interpolated shading.
For interpolated shading, the CData of FaceVertexCData properties
must be specified as truecolor, RGB, one color per vertex.
contourf does not happen to create the appropriate data structures
that way.

--
  "Man's life is but a jest,
   A dream, a shadow, bubble, air, a vapor at the best."
                                         -- George Walter Thornbury

Subject: Contour graph help!

From: Zijia Li

Date: 3 Jul, 2008 18:42:02

Message: 20 of 22

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <g4j4om$1v8$1@canopus.cc.umanitoba.ca>...
> In article <g4j3va$8ba$1@fred.mathworks.com>,
> Zijia Li <triplezzz21@gmail.com> wrote:
> >so, no one knows why it's giving that error message?
>
> You are probably referring to the error message you
mentioned earlier
> in the thread when you turned on shading interp,
> "warning:color data is not set for interpolated shading"
>
> The reason it is giving you that error is that ... you haven't
> set the color data needed for interpolated shading.
> For interpolated shading, the CData of FaceVertexCData
properties
> must be specified as truecolor, RGB, one color per vertex.
> contourf does not happen to create the appropriate data
structures
> that way.
>
> --
> "Man's life is but a jest,
> A dream, a shadow, bubble, air, a vapor at the best."
> -- George Walter
Thornbury



How exactly do you do that?

Subject: Contour graph help!

From: Zijia Li

Date: 7 Jul, 2008 14:57:33

Message: 21 of 22

"Zijia Li" <triplezzz21@gmail.com> wrote in message
<g4j6hq$bha$1@fred.mathworks.com>...
> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> message <g4j4om$1v8$1@canopus.cc.umanitoba.ca>...
> > In article <g4j3va$8ba$1@fred.mathworks.com>,
> > Zijia Li <triplezzz21@gmail.com> wrote:
> > >so, no one knows why it's giving that error message?
> >
> > You are probably referring to the error message you
> mentioned earlier
> > in the thread when you turned on shading interp,
> > "warning:color data is not set for interpolated shading"
> >
> > The reason it is giving you that error is that ... you
haven't
> > set the color data needed for interpolated shading.
> > For interpolated shading, the CData of FaceVertexCData
> properties
> > must be specified as truecolor, RGB, one color per vertex.
> > contourf does not happen to create the appropriate data
> structures
> > that way.
> >
> > --
> > "Man's life is but a jest,
> > A dream, a shadow, bubble, air, a vapor at the best."
> > -- George Walter
> Thornbury
>
>
>
> How exactly do you do that?

Anyone?

Subject: Contour graph help!

From: Ilya Rozenfeld

Date: 7 Jul, 2008 16:34:01

Message: 22 of 22

I don't think 'contourf' is appropriate command. Try
using 'pcolor'.

"Zijia Li" <triplezzz21@gmail.com> wrote in message
<g4tast$rop$1@fred.mathworks.com>...
> "Zijia Li" <triplezzz21@gmail.com> wrote in message
> <g4j6hq$bha$1@fred.mathworks.com>...
> > roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> > message <g4j4om$1v8$1@canopus.cc.umanitoba.ca>...
> > > In article <g4j3va$8ba$1@fred.mathworks.com>,
> > > Zijia Li <triplezzz21@gmail.com> wrote:
> > > >so, no one knows why it's giving that error message?
> > >
> > > You are probably referring to the error message you
> > mentioned earlier
> > > in the thread when you turned on shading interp,
> > > "warning:color data is not set for interpolated
shading"
> > >
> > > The reason it is giving you that error is that ...
you
> haven't
> > > set the color data needed for interpolated shading.
> > > For interpolated shading, the CData of
FaceVertexCData
> > properties
> > > must be specified as truecolor, RGB, one color per
vertex.
> > > contourf does not happen to create the appropriate
data
> > structures
> > > that way.
> > >
> > > --
> > > "Man's life is but a jest,
> > > A dream, a shadow, bubble, air, a vapor at the
best."
> > > -- George
Walter
> > Thornbury
> >
> >
> >
> > How exactly do you do that?
>
> Anyone?
>

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com