From: Ken on
Hi,

Essentially what I want to do is to plot those y1, y2 vars with the same x axes, and then plot some points on each of the y1 and y2 graphs, I have the following plotyy...

[ax, h1, h2] = plotyy(x,y1, x,y2);
but then the scatter plot with points '*' on top of both plots produce new graph which I don't want. I only want plots on the the same graph.

I have seen such graphs with Matlab before, but I don't know how to do it.
Can you tell me how to do it?

Thanks,

-ken
From: someone on
"Ken " <kk61(a)cornell.edu> wrote in message <hofod6$rqn$1(a)fred.mathworks.com>...
> Hi,
>
> Essentially what I want to do is to plot those y1, y2 vars with the same x axes, and then plot some points on each of the y1 and y2 graphs, I have the following plotyy...
>
> [ax, h1, h2] = plotyy(x,y1, x,y2);
> but then the scatter plot with points '*' on top of both plots produce new graph which I don't want. I only want plots on the the same graph.
>
> I have seen such graphs with Matlab before, but I don't know how to do it.
> Can you tell me how to do it?
>
> Thanks,
>
> -ken

If I understand, maybe you need to use:

hold on

before you plot the '*' points.

Otherwise, I suggest you show us some of your code.
From: Ken on
Hi,

Thanks.
Hold on doesn't work.
Try the following line with:
[ax, h1, h2] = plotyy(x,y1, x,y2);
hold on
scatter(x(1), y1(1), '*');
hold off

It plots scatter on a seperate window.

I want it on the same window. I know it is possible, but don't know how.
Can you tell me how to do it?

Thanks,

-ken


"someone" <someone(a)somewhere.net> wrote in message <hofrvh$8km$1(a)fred.mathworks.com>...
> "Ken " <kk61(a)cornell.edu> wrote in message <hofod6$rqn$1(a)fred.mathworks.com>...
> > Hi,
> >
> > Essentially what I want to do is to plot those y1, y2 vars with the same x axes, and then plot some points on each of the y1 and y2 graphs, I have the following plotyy...
> >
> > [ax, h1, h2] = plotyy(x,y1, x,y2);
> > but then the scatter plot with points '*' on top of both plots produce new graph which I don't want. I only want plots on the the same graph.
> >
> > I have seen such graphs with Matlab before, but I don't know how to do it.
> > Can you tell me how to do it?
> >
> > Thanks,
> >
> > -ken
>
> If I understand, maybe you need to use:
>
> hold on
>
> before you plot the '*' points.
>
> Otherwise, I suggest you show us some of your code.
From: Rob Campbell on
This example code may help you to overlay stuff in the way that you want. It does an overlay without using hold; instead it generates a second axis in the same position as the first. An example similar to this is discussed somewhere in the Matlab docs.

clf
plot(randn(1,100),'r')
pos=get(gca,'position');
axes('position',pos)
plot(randn(1,100),'ob')
set(gca,'color','none','yaxislocation','right')

From: Ken on
Thanks,

I have the similar function without using the plotyy:
ax1 = gca;
hl1 = line(x,y1,'Color','b');

hl3 = line(x, y2,'Color','r','Marker', '*','Parent',ax1);
set(ax1,'XColor','b','YColor','b');

ax2 = axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');

scatter(ax2, x(1), y1(1));

but the problem is that the scatter plot erases the graph(x, y2) which is I don't want. I want to plot on the top of both exiting graphs(x, y1) and (x, y2).

I appreciate if someone can help me on this.

Thanks,

-ken


"Rob Campbell" <matlab(a)robertREMOVEcampbell.removethis.co.uk> wrote in message <hogbi9$li9$1(a)fred.mathworks.com>...
> This example code may help you to overlay stuff in the way that you want. It does an overlay without using hold; instead it generates a second axis in the same position as the first. An example similar to this is discussed somewhere in the Matlab docs.
>
> clf
> plot(randn(1,100),'r')
> pos=get(gca,'position');
> axes('position',pos)
> plot(randn(1,100),'ob')
> set(gca,'color','none','yaxislocation','right')
>