Rescale 2nd axis using yyaxis (Right Axis)
12 次查看(过去 30 天)
显示 更早的评论
hi, I have a plot using the new yyaxis function in R2016b.
I want to change the scale on the Right Axis. after searching google and attempting several solutions none seem to work. This was my last attempt.
yyaxis right
plot(x,y,'*--','Color',[0 1 0]);
grid on
xlabel('x-axis','Fontsize',8);
ylabel('Avg Intensity','Fontsize',8);
ax = gca;
ylim=ax.YAxis(2).Limits
mn=min(ylim(:))
mx=max(ylim(:))
ylim([0.5*mn,mx])
h = ax.Yaxis(2);
ylim([0.5*min(h.YData), max(h.YData)])
Thanks Jason
0 个评论
采纳的回答
dpb
2016-12-23
The line
ylim=ax.YAxis(2).Limits
aliases the builtin function ylim so that
ylim([0.5*min(h.YData), max(h.YData)])
doesn't work as intended.
Try something like (after a "yyaxis right" command to ensure it is gca)
y2lims=ylim; % return limits
% do whatever manipulations on those values wanted here
ylim([nulowLim nuUplim])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!