how to set axis with different interval ?

23 次查看(过去 30 天)
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