Set and enforce axis properties immediately
Mostrar comentarios más antiguos
I have visualization code along the following lines:
subplot(1, 2, 1);
scatter3(N(:,1), N(:,2), N(:,3), '.');
drawnow;
hold on;
for r = 1 : NUM
% ... heavy calculations here
trisurf(Tri(FBtri), XYZ(:,1), XYZ(:,2), XYZ(:,3));
drawnow;
hold on;
end
set(gca, 'XDir', 'reverse');
% End subplot 1
subplot(1, 2, 2);
% Similar code
set(gca, 'XDir', 'reverse');
% End subplot 2
% So on, and so forth...
I need to reverse the X axis, and have found that it only works if I add the property setter after the entire code block for each subplot. This results in the entire subplot being rendered, and then visibly being reversed.
Is there a way that this property can be set and enforced before any contained future objects are computed/rendered, so that everything is shown reversed along the specified axis in the first place?
I would also welcome suggestions towards improving my usage of hold and drawnow, and on how to set and enforce axis reversal (or any axis property in general) for all subplots in the beginning itself with a single call to set, if that's possible.
Respuesta aceptada
Más respuestas (2)
Sean de Wolski
el 14 de Oct. de 2014
0 votos
If you don't need the intermediate updates in the loop, pull the drawnow out of the loop and call it once after setting xdir reverse. This way the graphics are only updated after the loop which will save time and it will only show the final result which includes xdir reversed.
1 comentario
slaiyer
el 14 de Oct. de 2014
Robert Cumming
el 14 de Oct. de 2014
when you create your subplot set the Xdir then:
subplot ( 1, 2, 1, 'xdir', 'reverse' );
% your other code goes here
subplot(1, 2, 2, 'xdir', 'reverse' );
If this doesn't work it could be due to you use cla - which resets all axes properties, if thats the case then change the default behaviour of the nextplot command (then you dont need hold on).
subplot ( 1, 2, 1, 'xdir', 'reverse', 'nextplot', 'add' );
Categorías
Más información sobre Subplots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!