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 Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by