Plotyy changes line style every time in for loop

조회 수: 1 (최근 30일)
Abdulaziz
Abdulaziz 2013년 9월 5일
Hi All Please, I need help with inserting plotyy in for loop and every time the line styel and color will be changed. I have tried this
plotStyle = {'^b','ok:','or','og','om','oc','Xk','b+','r:','Xg','ok','or','g:'};
for j=1:n
figure(10+tt)
[AX,H1,H2]=plotyy(x{j},y{j},x{j},y_Cp{j},'plot');
set(get(AX(1), 'Ylabel'),'String',' Power (W)'); set(get(AX(2),'Ylabel'),'String','Power Coefficient (Cp)');
set(H1,'LineStyle',plotStyle{j}); set(H2,'LineStyle', plotStyle{j});
tt=tt+1;
Thanks in advance
end

채택된 답변

Walter Roberson
Walter Roberson 2013년 9월 6일
[AX,H1,H2] = plotyy(x{j}, y{j}, x{j}, y_Cp{j}, @(X,Y) plot(X,Y,plotstyle{j}), @(X,Y) plot(X,Y,plotstyle{j}));
or
plotLineMarker = {'^', 'o', 'o', 'o', 'o', 'o', 'x', '+', 'none', 'x', 'o', 'o', 'none'};
plotLineStyle = {'none', ':', 'none', 'none', 'none', 'none', 'none', 'none', ':', 'none', 'none', 'none', ':'};
plotLineColor = {'b', 'k', 'r', 'g', 'm', 'c', 'k', 'b', 'r', 'g', 'k', 'r', 'g'};
[AX, H1, H2] = plotyy(x{j}, y{j}, x{j}, y_Cp{y},
set( [H1, H2], 'LineStyle', plotLineStyle{j}, 'Color', plotLineColor{j}, 'Marker', plotLineMarker{j});
  댓글 수: 1
Abdulaziz
Abdulaziz 2013년 9월 6일
I want to say thank you very much Walter. you have been of great help for long time
Warmest Regards

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

추가 답변 (2개)

A Jenkins
A Jenkins 2013년 9월 5일
There are separate 'LineStyle' and 'Marker' settings.
'LineStyle' just changes the Line Property. Valid choices are:
{-} -- : -. none
A similar set() command with 'Marker' would be used to change the marker property.
+ o * . x s d ^ v > < p h none
More adjustments (color, etc) can be found here:

Abdulaziz
Abdulaziz 2013년 9월 5일
편집: Image Analyst 2013년 9월 5일
To be more clear I generate the same thing for one y coordinate plot as following
plotStyle = {'^b','ok:','or','og','om','oc','Xk','b+','r:','Xg','ok','or','g:'};
for j=1:n
plot(x_RPM{j},y_P{j},plotStyle{j});
xlabel('Rotational Speed (RPM)');ylabel('Power (W)');
title(['For Pitch Angle of ',PitchAn,'Power vs. RPM']);
legendInfo{j}=['U=' num2str(U(j,1))];
hold on
end
legend(legendInfo)
But I do not know how to do the same thing for the two y coordinate plotyy
Any suggestion is appreciated hold off

카테고리

Help CenterFile 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