How to setting one horizontal axis for 2 subplot?
    5 views (last 30 days)
  
       Show older comments
    
Hi all,
I have a question about subplot. How can we plot 2 suplots, but only one horizontal axis.
 subplot(3, 1, 1:2);
plot(rand(10, 1), 'b.-', 'LineWidth', 2);
grid on;
subplot(3, 1, 3);
plot(rand(10, 1), 'b.-', 'LineWidth', 2);
grid on;
My expection as:

Thank you so much
0 Comments
Accepted Answer
More Answers (1)
  Martin Pryde
 on 12 Oct 2022
        
      Edited: Martin Pryde
 on 12 Oct 2022
  
      ax1 = subplot(3,1,1:2);
plot(ax1,rand(10,1),'b.-','LineWidth',2);
ax2 = subplot(3, 1, 3);
plot(ax2,rand(10,1),'b.-','LineWidth',2);
grid(ax1,'on');
xlim(ax1,[1,10]);
xticks(ax1,1:10);
xticklabels(ax1,{})
grid(ax2,'on');
xticks(ax2,1:10);
xlim(ax2,[1,10]);
0 Comments
See Also
Categories
				Find more on Subplots in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




