axes setting problem

Dear All, I am trying two plot two lines in the same axes using double Y-axis. I found an example in the help pages and adjusted for my needs. I can not get it, why does it show an error:
Error using: set
Value must be a handle
The error occurs in the third line of the following code:
line(ax,ay,'Color','r','LineWidth',2);
ax1 = gca;
set(ax1,'Ycolor','r','YLim',[0 500], 'ylabel', 'Distance(m)', 'FontSize',22, 'FontName','Helvetica');
ax2= axes('Position',get(ax1,'Position'),'YAxisLocation','right', 'Color','none', 'YColor','b', 'YLim',[0 3], 'ylabel','Distance(m)', 'FontSize',22, 'FontName','Helvetica');
line(bx,by,'Color','b','LineWidth',2,'Parent',ax2);
Please could you give me any clue?

 채택된 답변

Andreas Goser
Andreas Goser 2012년 4월 26일

0 개 추천

The issue is in how you use YLABEL. Try:
set(ax1,'ylabel', 'Distance(m)');
The point is that you need a different type of handle here, not the axis handle. Insteadt run
set(ax1,'Ycolor','r','YLim',[0 500], 'FontSize',22, 'FontName','Helvetica');
set(get(gca,'YLabel'),'String','Distance (m)')

댓글 수: 2

Elis Kulla
Elis Kulla 2012년 4월 26일
Worked like a beauty.
It looks like the handles for axes are different from those of labels.
Thank you Mr. Goser
Andreas Goser
Andreas Goser 2012년 4월 26일
Yes, it is sometimes tricky with all the parent and child handles!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by