how to set axis with different interval ?

20 views (last 30 days)
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 ?

Accepted Answer

Star Strider
Star Strider on 17 Jan 2021
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:
.

More Answers (1)

Adam Danz
Adam Danz on 17 Jan 2021
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')

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!