필터 지우기
필터 지우기

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

조회 수: 4 (최근 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?

답변 (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 CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by