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])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by