ここでの答えは既に説明しています。ここではx軸とy軸を分ける最後のステップを示します。
f = figure ('color', 'white');
% create the axes and set some properties
ax = axes ('parent', f, 'box', 'off', 'nextplot', 'add', 'XMinorTick', 'on', 'YMinorTick', 'on');
% plot some data
plot (ax, 0:10, [0:10].^2, 'rx-')
% modify the x and y limits to below the data (by a small amount)
ax.XLim(1) = ax.XLim(1)-(ax.XTick(2)-ax.XTick(1))/4;
ax.YLim(1) = ax.YLim(1)-(ax.YTick(2)-ax.YTick(1))/4;
% Set the tick direction
ax.TickDir = 'out';
% draw the plot to generate the undocumented vertex data var
drawnow()
%% R2015a
% X, Y and Z row of the start and end of the individual axle.
ax.XRuler.Axle.VertexData(1,1) = 0;
ax.YRuler.Axle.VertexData(2,1) = 0;
%% R2015b
% extract the x axis vertext data
% X, Y and Z row of the start and end of the individual axle.
vd = get(ax.XAxis.Axle,'VertexData');
% reset the zero value
vd(1,1) = 0;
% Update the vertex data
set(ax.XAxis.Axle,'VertexData',vd);
% repeat for Y (set 2nd row)
vd = get(ax.YAxis.Axle,'VertexData');
vd(2,1) = 0;
set(ax.YAxis.Axle,'VertexData',vd);
編集:あなたがズームインまたは例えばパン場合頂点が軸/フィギュアのサイズを変更するたびに、MATLABが再現しているものですか。
これを解決するためにリスナーを追加することで、これに対抗しようとすることができます(ここでは、文書化されていない機能を使用しています)。我々はかなり多くの時間と呼ばれるMarkedClean
イベントを使用することができます。
編集2は0
function resetVertex (ax)
% extract the x axis vertext data
% X, Y and Z row of the start and end of the individual axle.
ax.XAxis.Axle.VertexData(1,1) = 0;
% repeat for Y (set 2nd row)
ax.YAxis.Axle.VertexData(2,1) = 0;
% You can modify the minor Tick values by modifying the vertex data
% for them, e.g. remove any minor ticks below 0
ax.XAxis.MinorTickChild.VertexData(:,ax.XAxis.MinorTickChild.VertexData(1,:)<0) = [];
ax.YAxis.MinorTickChild.VertexData(:,ax.YAxis.MinorTickChild.VertexData(1,:)<0) = [];
end
の下に小目盛りをオフにするコードを追加しました(R2015bのみ示す):あなたが機能をresetVertex
addlistener (ax, 'MarkedClean', @(obj,event)resetVertex(ax));
のようなものがあります
注:これは文書化されていない機能を使用します - >これはMatlabの特定のバージョンでのみ機能するかもしれません(私はコードを追加しましたr2015a & r2015b)、Matlabはプロットで行うことに応じて頂点データを再作成することができます。
別のオプションは 'axis([minx-minx/10 maxx miny maxy])'やその他の要素1/10以外 – shamalaia