truncAxis (break X/Y axis | 截断坐标轴)

Create broken axes by truncating X and/or Y axis, supporting logarithmic scaling and reversed axis and resizing the axes based on X/Y range.

現在この提出コンテンツをフォロー中です。

Basic usage
  • truncAxis(gca, 'X', [x1, x2])
  • truncAxis(gca, 'Y', [y1, y2])
  • truncAxis(gca, 'X', [x1, x2], 'Y', [y1, y2])
Where:
  • x1, x2: break points on X-axis, satisfying XLim(1) < x1 < x2 < XLim(2)
  • y1, y2: break points on Y-axis, satisfying YLim(1) < y1 < y2 < YLim(2)
Demo 1
X = linspace(0, 2*pi, 100);
Y = exp(.3*X).*sin(3*X);
scatter(X, Y, 'LineWidth',1);
set(gca, 'Box','on', 'NextPlot','add', 'LineWidth',1.5, ...
'FontName','Times New Roman', 'FontSize',15, ...
'XLim',[0, 6], 'YLim',[-6, 6], 'XColor','r','YColor','b', ...
'XMinorTick','on', 'YMinorTick','on', 'TickDir','out', 'TickLength',[.005,.001]);
truncAxis('X',[4, 4.5], 'Y',[2, 3], 'XResize','on', 'YResize','on')
legend
Demo 2
% Generate sample data
Data = [randi([20, 35], [5, 1]), randi([160, 190], [5, 1])];
err = rand([5, 2]) .* 5;
hold on
barHdl = bar(Data, 'BarWidth', 1, 'LineWidth',1);
% Customize bar colors and transparency
barHdl(1).FaceColor = [153, 153, 253] ./ 255;
barHdl(2).FaceColor = [255, 153, 154] ./ 255;
barHdl(1).FaceAlpha = 0.9;
barHdl(2).FaceAlpha = 0.9;
% Render and customize error bars
errorbar(barHdl(1).XEndPoints, Data(:, 1), err(:, 1), ...
'LineStyle', 'none', 'Color', 'k', 'LineWidth', 1);
errorbar(barHdl(2).XEndPoints, Data(:, 2), err(:, 2), ...
'LineStyle', 'none', 'Color', 'k', 'LineWidth', 1);
% Axes styling and label customization
ax = gca;
ax.YLim = [0, 200];
ax.LineWidth = 1;
ax.TickLength = [0.005, 0.001];
ax.Box = 'on';
ax.FontSize = 13;
ax.XTick = 1:5;
ax.XTickLabel = {'A', 'B', 'C', 'D', 'E'};
axMat = truncAxis('Y', [50, 155]);
axMat(1).Children(end).BaseLine.Color = 'none';
% Add legend
legend({'AAAAA', 'BBBBB'}, 'FontSize', 13);

引用

Zhaoxu Liu / slandarer (2026). truncAxis (break X/Y axis | 截断坐标轴) (https://jp.mathworks.com/matlabcentral/fileexchange/120288-truncaxis-break-x-y-axis), MATLAB Central File Exchange. に取得済み.

一般的な情報

MATLAB リリースの互換性

  • すべてのリリースと互換性あり

プラットフォームの互換性

  • Windows
  • macOS
  • Linux
バージョン 公開済み リリース ノート Action
2.0.1

Change cover.

2.0.0

Supporting logarithmic scaling and reversed axis and resizing the axes based on X/Y range.

1.0.0