How to have a x-axis with repeating values (non-unique)
29 ビュー (過去 30 日間)
古いコメントを表示
I am having some issues trying to reporduce a plot in MatLab, I have seen this layout of plot many times.
As an example here is the plot in Excel:
As you see the x-axis is reapeting on itself between 4-9 three times. If it is any help, in Excel I use category labels for the x-axis.
Is something like this possible in MatLab?
0 件のコメント
採用された回答
the cyclist
2021 年 4 月 7 日
編集済み: the cyclist
2021 年 4 月 7 日
I have not seen a plot of this style. It's a bit confusing to me. I'm curious what the color background regimes are. Training, testing, validation?
The solution will depend on whether the x data themselves repeat or not.
If the x values do not repeat, and you are just shifting regimes over, then you can just adjust the labels:
rng default
x = 4:21;
y = rand(size(x));
figure
plot(x,y)
set(gca,'XTick',x,'XTickLabel',4:9) % Note that the labels repeat, because there are not "enough" for the ticks
axis tight
I don't love this solution, because it breaks the correspondence between the label and the data. But maybe you need to do that.
If the data themselves repeat, you'll need to use a third variable to force the different regimes to not overlap. Then I think you'll still need the above labeling method.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!