Surface plot with semilog z-axis: how to keep the same axis limit for iterative plots?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all,
I have an algorithm which generates 4 surfaces iteratively. I'd like to set the z-axis to semilog scale and keep the same z-axis limit for all iterations. Here is the code:
x = 1:5;
y = 1:5;
axisLim = 0.0007;
for i = 1:4
subplot(1, 4, i)
surf(x, y, errPreStore{i});
axi_lim = [0, axisLim];
zlim(axi_lim)
axis tight
axis square
set(gca, 'ZScale', 'log');
end
However from the surface plot you can see that the z-axis does not remain the same for these 4 plots. How can I fix it? I've attached the test.mat file so you can import and plot.
Thanks!
0 comentarios
Respuesta aceptada
dpb
el 3 de Mayo de 2017
Editada: dpb
el 3 de Mayo de 2017
Use
zlim([zMIN zMAX])
that you want before beginning the iteration.
Didn't read carefully enough, sorry...you're using mutually exclusive commands and the last in effect are those from axis...
doc axis
...
axis tight sets the axis limits to the range of the data and sets the
XLimMode, YLimMode, and ZLimMode properties to auto.
Use axis tight manual to set the limit mode properties to manual.
...
So, right after you set the z-axis limit manually your overwrite it and set it back to 'auto' with the axis tight call.
Try something more like...
for i = 1:4
hAx(i)=subplot(1, 4, i); % save the axes handles always
surf(x, y, errPreStore{i});
end
set(hAx,'zscale','log')
axis(hAx,'square')
axis(hAx,'tight', 'manual')
set(hAx,'zlim',axi_lim)
which results in
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!