Vertically stacked subplots with x-axis labels only at the bottom

120 ビュー (過去 30 日間)
Douglas Anderson
Douglas Anderson 2013 年 1 月 25 日
コメント済み: Bill Tubbs 2020 年 5 月 30 日
Hi,
I searched and couldn't find the answer to what I am guessing is a simple problem. I need several waveforms in separate subplots, all with the same X limits. The tick marks aren't a problem, but the numbers effectively limit the number of subplots, squeezing the data out!
Is there a simple way to have only one set of x coordinate labels and a label 'time' below that?
'axis off' won't work because it removes the ticks and the background, and I still want them.
Thanks.
Doug Anderson

回答 (3 件)

Sean de Wolski
Sean de Wolski 2013 年 1 月 25 日
How about just turning off the 'XTick'
for ii = 1:9
subplot(9,1,ii);
plot(rand(1,10));
if ii < 9
set(gca,'XTick',[]);
end
end
  2 件のコメント
Bill Tubbs
Bill Tubbs 2020 年 5 月 30 日
This is only good if all the plots have exactly the same x limits. I guess I can assume from this that Matlab's plot function doesn't have the sharex=True and sharey feature that Python's matplotlib does.
Bill Tubbs
Bill Tubbs 2020 年 5 月 30 日
Apparently there is a function called linkaxes(ax,'x') to make sure they are aligned. See here for an example.

サインインしてコメントする。


Nike
Nike 2013 年 1 月 25 日
編集済み: Nike 2013 年 1 月 25 日
Hi Douglas,
Why dont you try turning the XTicks off for all the wavforms except the bottom one or ty using this
use this in the for loop you use to subplot to delete the numbers in the X axis
%
set(gca,'xtick',[],'ytick',[])
Use this after th for loop to set the numbers at the bottom of the screen
set(gca,'xtickMode', 'auto')
Hope this helps
Nike

Thorsten
Thorsten 2013 年 1 月 25 日

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by