Rescale 2nd axis using yyaxis (Right Axis)

15 visualizaciones (últimos 30 días)
Jason
Jason el 23 de Dic. de 2016
Comentada: Jason el 23 de Dic. de 2016
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

Respuesta aceptada

dpb
dpb el 23 de Dic. de 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])

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by