0

グラフを固定軸にし、データを 1 つずつプロットします。すべてが既知ですが、ホールドオフを使用して最初のデータセットを削除すると、軸の制限も忘れられ、2 番目のデータセットに新しい制限が自動的に割り当てられます。別々のデータが同じ図にプロットされるたびに、軸を同じに保つことはどうにかして可能ですか?

今のところコードは次のとおりです。

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: xlabel、ylabel、xlim などを常に呼び出さずにループでホールド オンとホールド オフを使用してサブプロットをプロットします 。しかし、私はそれをまったく理解していません。親の図、replacechildren、nextplot などを使用していますが、これらは私がよく知らず、多くの情報を見つけることもできません。

4

1 に答える 1

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]
于 2014-11-05T00:12:22.577 に答える