Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

different markers in plotyy

5 views
Skip to first unread message

Mike

unread,
May 7, 2008, 8:50:05 PM5/7/08
to
Hi

I use plotyy to plot two y1 and one y2(on the right).
I use:
[AX,H1,H2] = plotyy(x,[y1,y2],x,y3);
legend([H1;H2],'y1',y2',y3');
set(AX,'xlim',[min(x) max(x)])
set([H1;H2],'Color','k','marker','o')
Then three lines will be all in marker o.
Can I have distinct markers please?

thank you in advance.
Mike

Mike

unread,
May 7, 2008, 10:31:19 PM5/7/08
to
On May 8, 8:50 am, Mike <Sulfate...@gmail.com> wrote:
> Hi
>
> I use plotyy to plot two y1 and one y2(on the right).
> I use:
> [AX,H1,H2] = plotyy(x,[y1,y2],x,y3);
> legend([H1;H2],'y1',y2',y3');
> set(AX,'xlim',[min(x) max(x)])
> set([H1;H2],'Color','k','marker','o')
^^^^^
Can this be an array?
I tried ['o' 's'
'd']. Doesn't work at all.

Walter Roberson

unread,
May 8, 2008, 12:59:38 PM5/8/08
to
In article <1006d066-8a73-4f29...@u12g2000prd.googlegroups.com>,
Mike <Sulfa...@gmail.com> wrote:

Markers = '.ox+*sdv^<>ph';
noMarkers = length(Markers);

H1c = findobj(H1,'Type','line');
H2c = findobj(H2,'Type','line');
linehandles = [H1c;H2c];
for K = 1:length(linehandles)
set(linehandles(K),'Marker',Markers(1+mod(K-1,noMarkers)));
end


This code will cycle through the line markers in the order
given in Markers. The code is specifically designed to take into
account the possibility that [y1,y2] or y3 might be multidimensional
and so might create multiple lines on the plot: as you wanted distinct
markers, distinct markers are used for each of the resulting lines
[as far as possible considering there are only a limited number of
markers available]. The code could be simplified quite a bit if
there were a guarantee that [y1,y2] was going to result in exactly
two lines and that y3 was going to result in exactly one line.
--
"Do not on any account attempt to write on both sides of
the paper at once." -- Walter C. Sellar

Mike

unread,
May 8, 2008, 11:00:14 PM5/8/08
to
On May 9, 12:59 am, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <1006d066-8a73-4f29-b050-2abdf7471...@u12g2000prd.googlegroups.com>,
thank you very much. It works.

Mike

0 new messages