Rescaling and extending the axes of compass plots
显示 更早的评论
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))];
回答(2 个)
Vinod Sudheesh
2015-5-27
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
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!