From: JMvanwessem van Wesesm on
TideMan <mulgor(a)gmail.com> wrote in message <e6464ee7-563c-47e9-8d2d-03112cab860d(a)w9g2000prb.googlegroups.com>...
> On Mar 10, 10:47 am, "JMvanwessem van Wesesm" <jmvanwes...(a)gmail.com>
> wrote:
> > Well, that doesn't work. It plots in 1 graph of course, but it uses the range of 1 function and not of both function seperately. I just want the first function to be defined by the colorbar, and the other with contour-labels. Seperately setting the Z-range for both functions doesnt work, it overwrites eachother.
>
> Look, I do this all the time with tides. It's called a "cotidal
> chart".
> I use contourf for the amplitude, then hold on, and contourc for the
> phase lines.
> Amplitudes go from zero to 1 or 2 and phases go from 0 to 360 (there
> is a problem when it goes from 360 back to zero, but that happens with
> any contouring program).
> So, you must be doing something wrong.
> Post your code so that we can see what it is.
>

Aah thanks for your reply. You almost helped me, but I can't seem to get the ranges fixed. What happens is that if I would plot phases and amplitudes together it still takes the same range. As to draw one as a totally black contour...

This is my code. It was not my optimal one because I kept changing stuff, but this is basically what I am trying to do:

hold on
[c,d]=contourf(X,Y,Z1';
title
colormap gray; colorbar;
[e,f]=contour(X,Y,Z2);
set(f,'ShowText','on','TextStep',get(f,'LevelStep')*2)
clabel(e,f,'FontSize',13,'Color','w','Rotation',0)
hold off
From: TideMan on
On Mar 10, 9:51 pm, "JMvanwessem van Wesesm" <jmvanwes...(a)gmail.com>
wrote:
> TideMan <mul...(a)gmail.com> wrote in message <e6464ee7-563c-47e9-8d2d-03112cab8...(a)w9g2000prb.googlegroups.com>...
> > On Mar 10, 10:47 am, "JMvanwessem van Wesesm" <jmvanwes...(a)gmail.com>
> > wrote:
> > > Well, that doesn't work. It plots in 1 graph of course, but it uses the range of 1 function and not of both function seperately. I just want the first function to be defined by the colorbar, and the other with contour-labels. Seperately setting the Z-range for both functions doesnt work, it overwrites eachother.
>
> > Look, I do this all the time with tides.  It's called a "cotidal
> > chart".
> > I use contourf for the amplitude, then hold on, and contourc for the
> > phase lines.
> > Amplitudes go from zero to 1 or 2 and phases go from 0 to 360 (there
> > is a problem when it goes from 360 back to zero, but that happens with
> > any contouring program).
> > So, you must be doing something wrong.
> > Post your code so that we can see what it is.
>
> Aah thanks for your reply. You almost helped me, but I can't seem to get the ranges fixed. What happens is that if I would plot phases and amplitudes together it still takes the same range. As to draw one as a totally black contour...
>
> This is my code. It was not my optimal one because I kept changing stuff, but this is basically what I am trying to do:
>
> hold on
> [c,d]=contourf(X,Y,Z1';
> title
> colormap gray; colorbar;
> [e,f]=contour(X,Y,Z2);
> set(f,'ShowText','on','TextStep',get(f,'LevelStep')*2)
> clabel(e,f,'FontSize',13,'Color','w','Rotation',0)
> hold off

Well, apart from the apostrophe instead of right parenthesis in
contourf and the incomplete title, this code works for me.
Perhaps you have screwed up Z1 and/or Z2?
From: JMvanwessem on
TideMan <mulgor(a)gmail.com> wrote in message <1a15619d-0c58-4156-b8c2-aa92d27a534e(a)x1g2000prb.googlegroups.com>...
> On Mar 10, 9:51 pm, "JMvanwessem van Wesesm" <jmvanwes...(a)gmail.com>
> wrote:
> > TideMan <mul...(a)gmail.com> wrote in message <e6464ee7-563c-47e9-8d2d-03112cab8...(a)w9g2000prb.googlegroups.com>...
> > > On Mar 10, 10:47 am, "JMvanwessem van Wesesm" <jmvanwes...(a)gmail.com>
> > > wrote:
> > > > Well, that doesn't work. It plots in 1 graph of course, but it uses the range of 1 function and not of both function seperately. I just want the first function to be defined by the colorbar, and the other with contour-labels. Seperately setting the Z-range for both functions doesnt work, it overwrites eachother.
> >
> > > Look, I do this all the time with tides.  It's called a "cotidal
> > > chart".
> > > I use contourf for the amplitude, then hold on, and contourc for the
> > > phase lines.
> > > Amplitudes go from zero to 1 or 2 and phases go from 0 to 360 (there
> > > is a problem when it goes from 360 back to zero, but that happens with
> > > any contouring program).
> > > So, you must be doing something wrong.
> > > Post your code so that we can see what it is.
> >
> > Aah thanks for your reply. You almost helped me, but I can't seem to get the ranges fixed. What happens is that if I would plot phases and amplitudes together it still takes the same range. As to draw one as a totally black contour...
> >
> > This is my code. It was not my optimal one because I kept changing stuff, but this is basically what I am trying to do:
> >
> > hold on
> > [c,d]=contourf(X,Y,Z1';
> > title
> > colormap gray; colorbar;
> > [e,f]=contour(X,Y,Z2);
> > set(f,'ShowText','on','TextStep',get(f,'LevelStep')*2)
> > clabel(e,f,'FontSize',13,'Color','w','Rotation',0)
> > hold off
>
> Well, apart from the apostrophe instead of right parenthesis in
> contourf and the incomplete title, this code works for me.
> Perhaps you have screwed up Z1 and/or Z2?

oops, edited it a wrong. But you fixed it ok. But it doesnt work. I don't seem to get my point across. This plot indeed works, as it plots both. If I would plot them one by one, I would first get a contourf for Z1. This is a graph I already have. I now just want to put a new graph on top of it, a contourline plot. If I do this with the code above it overwrites the Z1 range by Z2 and it changes the contourf colour and makes it all black, which is obviously not what I want. I want the plots to be totally independent of each other.
From: TideMan on
On Mar 10, 11:39 pm, "JMvanwessem " <jmvanwes...(a)gmail.com> wrote:
> TideMan <mul...(a)gmail.com> wrote in message <1a15619d-0c58-4156-b8c2-aa92d27a5...(a)x1g2000prb.googlegroups.com>...
> > On Mar 10, 9:51 pm, "JMvanwessem van Wesesm" <jmvanwes...(a)gmail.com>
> > wrote:
> > > TideMan <mul...(a)gmail.com> wrote in message <e6464ee7-563c-47e9-8d2d-03112cab8...(a)w9g2000prb.googlegroups.com>...
> > > > On Mar 10, 10:47 am, "JMvanwessem van Wesesm" <jmvanwes...(a)gmail.com>
> > > > wrote:
> > > > > Well, that doesn't work. It plots in 1 graph of course, but it uses the range of 1 function and not of both function seperately. I just want the first function to be defined by the colorbar, and the other with contour-labels. Seperately setting the Z-range for both functions doesnt work, it overwrites eachother.
>
> > > > Look, I do this all the time with tides.  It's called a "cotidal
> > > > chart".
> > > > I use contourf for the amplitude, then hold on, and contourc for the
> > > > phase lines.
> > > > Amplitudes go from zero to 1 or 2 and phases go from 0 to 360 (there
> > > > is a problem when it goes from 360 back to zero, but that happens with
> > > > any contouring program).
> > > > So, you must be doing something wrong.
> > > > Post your code so that we can see what it is.
>
> > > Aah thanks for your reply. You almost helped me, but I can't seem to get the ranges fixed. What happens is that if I would plot phases and amplitudes together it still takes the same range. As to draw one as a totally black contour...
>
> > > This is my code. It was not my optimal one because I kept changing stuff, but this is basically what I am trying to do:
>
> > > hold on
> > > [c,d]=contourf(X,Y,Z1';
> > > title
> > > colormap gray; colorbar;
> > > [e,f]=contour(X,Y,Z2);
> > > set(f,'ShowText','on','TextStep',get(f,'LevelStep')*2)
> > > clabel(e,f,'FontSize',13,'Color','w','Rotation',0)
> > > hold off
>
> > Well, apart from the apostrophe instead of right parenthesis in
> > contourf and the incomplete title, this code works for me.
> > Perhaps you have screwed up Z1 and/or Z2?
>
> oops, edited it a wrong. But you fixed it ok. But it doesnt work. I don't seem to get my point across. This plot indeed works, as it plots both. If I would plot them one by one,  I would first get a contourf for Z1. This is a graph I already have. I now just want to put a new graph on top of it, a contourline plot. If I do this with the code above it overwrites the Z1 range by Z2 and it changes the contourf colour and makes it all black, which is obviously not what I want. I want the plots to be totally independent of each other.

Ah yes, my mistake..................
I had another look at my code.
What you have to do is to use contourc to calculate the contour lines,
then plot them over the contourf plot using plot, not contour.
Here's the snippet of code I use:
c=contourc([lonmn:dlon:lonmx],[latmn:dlat:latmx],phase,[0:30:360]);
[nrow,nc]=size(c);
ic=1;
while ic < nc
lev=c(1,ic);
nsub=c(2,ic);
cndx=[ic+1:ic+nsub];
xc=c(1,cndx);
yc=c(2,cndx);
m_plot(xc,yc,'k-',...
'LineWidth',1)
ic=ic + nsub + 1;
end

Note: I'm using the mapping toolbox m_map for this. It should work
with plot instead of m_plot.