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

2 views (last 30 days)
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?

Answers (1)

Alamanda Ponappa Poovaya
Alamanda Ponappa Poovaya on 3 Nov 2021
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:

Categories

Find more on Graphics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!