how to set axis with different interval ?

조회 수: 23 (최근 30일)
pruth
pruth 2021년 1월 17일
답변: Star Strider 2021년 1월 17일
I have data look like this !
x y
3 10
5 11
7 09
10 12
20 11
30 10
40 09
90 12
you see interval between x axiz values is not same, when i plot this, initial values are plotted very close to each other which doesnt look good.
I want each to put X axis values at same distance. how can i do that ?

채택된 답변

Star Strider
Star Strider 2021년 1월 17일
One option is to change the scale of the x-axis:
% x y
M = [ 3 10
5 11
7 09
10 12
20 11
30 10
40 09
90 12];
figure
plot(M(:,1), M(:,2), '-p')
Ax = gca;
Ax.XTick = M(:,1);
Ax.XScale = 'log';
axis([2 100 8 13])
xlabel('x')
ylabel('y')
producing:
.

추가 답변 (1개)

Adam Danz
Adam Danz 2021년 1월 17일
Two methods below show log scale and categorical x axes.
data = [
3 10
5 11
7 09
10 12
20 11
30 10
40 09
90 12];
clf()
ax(1) = subplot(3,1,1);
plot(ax(1), data(:,1),data(:,2))
title(ax(1),'Original data')
ax(2) = subplot(3,1,2);
plot(ax(2), data(:,1),data(:,2))
ax(2).XScale = 'log';
title(ax(2),'Log scale')
ax(3) = subplot(3,1,3);
plot(ax(3), categorical(data(:,1)),data(:,2))
title(ax(3),'Categorical')

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by