I wonder if there is a bug in the plot drawing. If I watch the axis properties in Inspector as I change XLim and YLim, the XTick and YTick variables adjust automatically to what they should be, but the ticks don't update on the figure itself. It doesn't appear to be a bug with the plot re-drawing, since saving the figure in a .fig file and loading it doesn't fix the issue. Neither does changing the Figure.Renderer or Axes.XTick and Axes.YTick properties.
Rescaling and extending the axes of compass plots
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Using 2014b.
I have multiple compass plots on the same figure, and I want to set them all to the same scale. When I try to set the axis limits of all the plots to those of the largest one, the smaller plots rescale so that the arrows are the right size. However, each entire plot itself simply shrinks. It does not extend the axes out to the specified limit or redraw the tick marks. How do I get it to keep the same size while rescaling the arrows and tick marks inside of it? The code I have goes as follows:
%make dummy data as described in the compass plot documentation
rng(0,'twister')
M = randn(20,20);
small_data = eig(M);
large_data = 2*small_data;
ax = zeros(2,2,2);%holds the axis limits for the 2 plots
figure
subplot(1,2,1)
compass(large_data)%draw the plot with larger arrows
curr_axis = gca;
ax(1,:,:) = [curr_axis.XLim; curr_axis.YLim];%pull out the axis limits for later comparing
subplot(1,2,2)
compass(small_data)%draw the plot with smaller arrows
curr_axis = gca;
ax(2,:,:) = [curr_axis.XLim; curr_axis.YLim];%pull out the axis limits for later comparing
%go back to the each plot and set their limits to the larger of the pair.
subplot(1,2,1)
curr_axis = gca;
curr_axis.XLim = [min(ax(:,1,1)) max(ax(:,1,2))];
curr_axis.YLim = [min(ax(:,2,1)) max(ax(:,2,2))];
subplot(1,2,2)
curr_axis = gca;
curr_axis.XLim = [min(ax(:,1,1)) max(ax(:,1,2))];
curr_axis.YLim = [min(ax(:,2,1)) max(ax(:,2,2))];
Réponses (2)
Vinod Sudheesh
le 27 Mai 2015
Hi Lawrence,
You could have both the "compass graphs" to be of same size by having the "axes" that contains these "compass graphs" to be of the same size. Note that the "compass" function re-sizes each of the "axes" while being invoked. You could consider the approach below to mitigate this
rng(0,'twister');
M = randn(20,20);
small_data = eig(M);
large_data = 2*small_data;
ax = zeros(2,2,2);
figure
subplot(1,2,1)
tmp=get(gca,'position');
compass(large_data);
set(gca,'position',tmp);
subplot(1,2,2)
tmp=get(gca,'position');
compass(small_data);
set(gca,'position',tmp);
Hope this helps !
Vinod
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!