Rescale 2nd axis using yyaxis (Right Axis)
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
dpb
am 23 Dez. 2016
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])
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!