How to add different range in x-axis plot?

16 vues (au cours des 30 derniers jours)
Alireza Moradikazerouni
Alireza Moradikazerouni le 29 Sep 2021
Modifié(e) : Dave B le 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 ?

Réponses (1)

Dave B
Dave B le 29 Sep 2021
Modifié(e) : Dave B le 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

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by