Creating multiple axis scales on one axis - Ex: fixed step, logarithmic, fixed step
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!