Linkaxes for all subplots in a for loop

两盒软妹~` 提交于 2019-12-12 02:19:34

问题


I am having difficulty making all of my subplots in a (3,4,i) plots have exactly the same axes, all starting at zero. The code I have so far is below but it returns all subplots with varying x and y scales.

Can anybody help?

%% plot 
for i = 1:num_bins;
    h = zeros(ceil(num_bins),1);
    h(i)=subplot(4,3,i); 
    plotmatrix(current_rpm,current_torque)
end
linkaxes(h,'xy');
axis([0 30 0 8]);

回答1:


You should move the memory allocation outside of the loop:

%% plot 
h = zeros(ceil(num_bins),1);
for i = 1:num_bins;
    h(i)=subplot(4,3,i); 
    plotmatrix(current_rpm,current_torque)
end
linkaxes(h,'xy');
axis([0 30 0 8]);


来源:https://stackoverflow.com/questions/15554899/linkaxes-for-all-subplots-in-a-for-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!