我希望我的图表能够固定轴,并逐个绘制数据。一切都已知,但如果我使用hold off删除第一组数据,它也会忘记轴上的限制并自动为第二组数据分配新的限制。 是否有可能在每次在同一图中绘制单独的数据时保持轴相同?
现在的代码是:
figure(4)
grid on
axis([xL yL zL])
for j = 1:n % n is amount of data sets
for i = 1:2 % two items drawn per data set
*plot data*
hold on
end
%This part has to be done every iteration again in order to make it work now
axis([xL yL zL])
xlabel = ...
ylabel
zlabel
title
pause(tstop)
hold off
end
经过一番搜索,我发现的唯一相关主题是; Matlab: Plot a subplot with hold on and hold off in a loop without always calling xlabel, ylabel, xlim, etc
但是我根本不明白。它使用父图,替换孩子,nextplot等我不熟悉的,也无法找到有关的信息。
答案 0 :(得分:1)
以下是一个可以轻松满足您需求的示例:
xlim([0 10]) %// set x-axis limits
ylim([0 10]) %// set y-axis limits
set(gca,'nextplot','replacechildren') %// prevent axis limits from changing with
%// each new plot
plot(3:8,3:8); %// note axis limits are kept as [0 10]
pause(1)
plot(5:7,5:7); %// note axis limits are kept as [0 10]