how to set axis with different interval ?
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
pruth
am 17 Jan. 2021
Beantwortet: Star Strider
am 17 Jan. 2021
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 ?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 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:
.
0 Kommentare
Weitere Antworten (1)
Adam Danz
am 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')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!