I'm plotting two curves using 2 different y-axes using plotyy. I would like to add markers to the data, and I can't figure out how to do that. The 'LineStyle' property will allow me to change from solid to dashed, etc; but won't let me change anything else.

 채택된 답변

Michelle Hirsch
Michelle Hirsch 2017년 3월 14일

1 개 추천

Easy Answer: If you are using R2016a or newer, use yyaxis instead of plotyy. yyaxis lets you use any plotting command, e.g.
yyaxis left
plot(x,y,'-*') % Plot into left axes
yyaxis right
plot(x,z,'-o') % Plot into right axes
If you are on an older release, there's an example in the doc for plotyy called changing linestyles that gets you close. The difference is that instead of setting values for the LineStyle property, you set values for the Marker property
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
hLine1.Marker = 'o';
hLine2.Marker = '*';
If you aren't familiar with graphics objects like hLine1, a few tips:
  • Display it at the command line to see some of the common properties you can control
  • In the command window, hit the TAB key after typing "hLine1." to see a list of all properties.
  • Learn more here: Using Graphics Objects

댓글 수: 5

Maurice
Maurice 2017년 3월 14일
Tried it. Didn't work.
Jan
Jan 2017년 3월 14일
편집: Jan 2017년 3월 14일
@Maurice: Please explain what did not work. Do you get an error message or does the result differ from your expectations? Explaining this would help Michelle to adjust her suggestion. Without knowing your code and the problem, suggesting anything else would be based on pure guessing.
+1 Jan. What version are you using? If older than 14b, change last 2 lines to:
set(hLine1,'Marker','o')
set(hLine2,'Marker','*')
Maurice
Maurice 2017년 3월 17일
Thank You Michelle! Your last suggestion did the trick!
if true
--------------------------------------------------- code start
This is an example for your case
Input is "Input_Data", two dimension matrix
Marker_Counter=1;
figure6=figure;
Markers = {'+','o','*','x','v','d','^','s','>','<'};
for i=1:10:size(Input_Data,1)
TPR=Input_Data(i:i+9,7);
FPR=Input_Data(i:i+9,8);
plot(FPR,TPR,strcat('-',Markers{Marker_Counter}));
Marker_Counter=Marker_Counter+1;
hold on
end
plot([0.5 1],[0.5 1],'--');
legend('Minpts = 100','Minpts = 200','Minpts = 300','Minpts = 400','Minpts = 500','Minpts = 600','Minpts = 700','Minpts = 800','Minpts = 900','Minpts = 1000','','Location','SouthEast');
xlabel('FPR or (1-Specificity)','FontSize',12,'FontWeight','bold'); ylabel('TPR or Spensitivity)','FontSize',12,'FontWeight','bold');
title('ROC Space');
close(gcf);
-------------------------------------------- code end
end
--------------------------------------- picture link preview

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

추가 답변 (0개)

카테고리

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

질문:

2017년 3월 14일

댓글:

Ali
2017년 10월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by