How to add different range in x-axis plot?

9 Ansichten (letzte 30 Tage)
Alireza Moradikazerouni
Alireza Moradikazerouni am 29 Sep. 2021
Bearbeitet: Dave B am 29 Sep. 2021
I am trying to plot two different datas;
1 - x-axis: [1:1:5]
2 - x-axis: [10:10:100]
then again plot 1>> [7:1:15]
generally, I wan to have a range of [10-100] between 5 to 7! each axis represnet dimensional and non-dmensional time.
Is there any way?
how can I keep changing the x - axis ?

Antworten (1)

Dave B
Dave B am 29 Sep. 2021
Bearbeitet: Dave B am 29 Sep. 2021
You can't have a 'broken' x axis, but you can fake it in several ways, here are a couple.
One way is to fake the ticks:
clf;hold on
plot(1:5,rand(1,5));
plot(6:10,rand(1,5))
plot(11:15,rand(1,5))
xticks([1 3 5 6 8 10 11 13 15])
xticklabels([1 3 5 10 50 100 7 9 11])
Another option is to 'fake' that they're all the same axes. tiledlayout is good for this:
figure
tcl = tiledlayout(1,3,'TileSpacing','tight');
nexttile
plot(1:5, rand(1,5))
xlim tight % axis tight in 2019b
box off
nexttile
plot(10:10:100, rand(1,10))
xlim tight % axis tight in 2019b
set(gca,'YColor','none')
box off
nexttile
plot(7:15, rand(1,9))
xlim tight % axis tight in 2019b
set(gca,'YColor','none')
box off
linkaxes(tcl.Children,'y') % make them use the same y limits

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by