Rescale 2nd axis using yyaxis (Right Axis)

4 ビュー (過去 30 日間)
Jason
Jason 2016 年 12 月 23 日
コメント済み: Jason 2016 年 12 月 23 日
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

採用された回答

dpb
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])
  1 件のコメント
Jason
Jason 2016 年 12 月 23 日
Thankyou

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by