Controlling markertype and linestyle in plotyy

Hi all
I am using plotyy in the following way:
[AX,H1,H2] = plotyy(x1,y1,x2,[y2a y2b],'plot')
How do I assign different linestyle and markertype to the lines [y2a y2b]?
Cheers
Jakob

 채택된 답변

the cyclist
the cyclist 2013년 3월 10일

4 개 추천

Here's one way:
x1 = 1:10;
y1 = 2:11;
x2 = 1:5;
y2a = 2:6;
y2b = 3:7;
figure
[ax h1 h2] = plotyy(x1,y1,x2,[y2a;y2b])
set(h1,'Marker','.','MarkerSize',8)
set(h2(1),'Marker','.','MarkerSize',24)
set(h2(2),'Marker','.','MarkerSize',48)
Note that I could instead have combined the setting of the Marker property for all objects like this:
set([h1;h2],'Marker','.')

댓글 수: 1

Brilliant. Thank you very much! I have been struggling with this one for a while.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Daniel Shub
Daniel Shub 2013년 3월 10일

0 개 추천

If you read the manual (doc plotyy) it tells you exactly how to do it in the example
set(H1,'LineStyle','--')
set(H2,'LineStyle,':')

댓글 수: 1

Notice that he wants to potentially set H2(1) and H2(2) to two different values, which is not so obvious.

댓글을 달려면 로그인하십시오.

Jakob Sievers
Jakob Sievers 2013년 3월 10일

0 개 추천

Im sorry, I should have been more specific: I know how to change the linestyles between H1 and H2. My question is: In this case I have 2 separate lines under H2. Is it possible to change the linestyle of those individually? Essentially what I would like to achieve is plotting these three lines with distinct line/marker features, without resorting to the user-contributed function "plotyyy".

카테고리

도움말 센터File Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by