How to add different range in x-axis plot?

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 ?

回答 (1 件)

Dave B
Dave B 2021 年 9 月 29 日
編集済み: Dave B 2021 年 9 月 29 日

1 投票

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

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

製品

リリース

R2019b

タグ

質問済み:

2021 年 9 月 29 日

編集済み:

2021 年 9 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by