Creating multiple axis scales on one axis - Ex: fixed step, logarithmic, fixed step
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Drishan Poovaya
el 3 de Nov. de 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:
0 comentarios
Ver también
Categorías
Más información sobre Discrete Data Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!