Creating multiple axis scales on one axis - Ex: fixed step, logarithmic, fixed step

2 ビュー (過去 30 日間)
Greg Vieira
Greg Vieira 2021 年 10 月 31 日
回答済み: Drishan Poovaya 2021 年 11 月 3 日
I would like to add multiple axis scales to one axis...
example: I have a time that goes from 0-1 second. I would like 0-0.3 to be normal scaling, 0.3-0.35 to be log scale, and 0.35-1 to be normal scaling.
Does anyone know a good way to do this?

回答 (1 件)

Drishan Poovaya
Drishan Poovaya 2021 年 11 月 3 日
It is possible to have multiple scales on one axis, but it is a little lenghty. Please have a look below
t = tiledlayout(1,3,'TileSpacing','none');
bgAx = axes(t,'XTick',[],'YTick',[],'Box','off');
bgAx.Layout.TileSpan = [1 3];
%First region
ax1 = axes(t);
plot(ax1,x,y);
ax1.Box = 'off';
xlim(ax1,[0 0.3])
xlabel(ax1, 'First Interval')
%second region
ax2 = axes(t);
ax2.Layout.Tile = 2;
plot(ax2,x,y);
ax2.YAxis.Visible = 'off';
ax2.Box = 'off';
xlim(ax2,[0.3 0.35])
set(ax2, 'XScale', 'log')
xlabel(ax2,'Second Interval')
ax2.YAxis.Visible = 'off';
% Third region
ax3 = axes(t);
ax3.Layout.Tile = 3;
plot(ax3,x,y);
ax3.YAxis.Visible = 'off';
ax3.Box = 'off';
xlim(ax3,[0.35 1])
xlabel(ax3,'Third Interval')
ax3.YAxis.Visible = 'off';
This code snippet will produce the axes with the X axis having the different scales as you mentioned.
Keep in mind that this method actually creates 3 different axes, so while plotting, you need to plot for each axes individually
Documentation:

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by