How to add text label to plot referenced to the second y-axis
12 次查看(过去 30 天)
显示 更早的评论
I would like to add a text label to my plotyy figure with the y-coordinate of the text(x,y,'string') referenced to the second y-axis. For example, I would like to have a text label at x=1 and y-axis(1)=3000 (text(1,3000,'string')) and another text label at x=2 and y-axis(2)=500, the second instance should be referenced to the second y-axis not the first.
I have tried,
[ax1,h1,h2]=plotyy(x1,y1,x2,y2);
text(ax1(2),xtext,ytext,'string')
"Error using text"
"First two or three arguments must be numeric doubles."
no luck yet, any suggestions would be appreciated. I do not have R2016 or I would have tried yyaxis left and yyaxis right.
0 个评论
回答(1 个)
Mischa Kim
2016-9-16
Mark, what about something like
x = 0:0.01:10;
y1 = exp(-0.05*x).*sin(x);
y2 = exp(-0.5*x).*sin(10*x);
[ax, h1, h2] = plotyy(x, y1, x, y2, 'plot');
text(x(1), y1(1),'string 1')
text(x(end),y2(1),'string 2')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!