I can't manage to stack plot 2 columns with the right graph size
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
inigo aguilera
il 3 Mar 2022
Commentato: inigo aguilera
il 7 Mar 2022
I´m trying to plot 4 graphs in 2 columns stacked vertically.
To do so I am trying the following subplot distribution. However when I do this my x axes (date/time) extends and the data looks very squashed up and I cannot manage to stack them. And ends up like in the image (does not include legend).
Anyone know how to make it look cleaner with the right axis size.
The point is to compare between graphs but the size seems to small.
Any help would be greatly apprecciated![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/913484/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/913484/image.png)
subplot(2,2,1)
subplot(2,2,2)
subplot(2,2,3)
subplot(2,2,4)
0 Commenti
Risposta accettata
Max Heimann
il 4 Mar 2022
You can alter the axis range with 'xlim'
figure('name','examplefigure')
% plot data
subplot(2,2,1)
plot(1:10,rand(1,10))
% set the x range
xlim([1 100])
% plot more data
subplot(2,2,2)
plot(1:10,rand(1,10))
subplot(2,2,3)
plot(1:10,rand(1,10))
subplot(2,2,4)
plot(1:10,rand(1,10))
% change the x range after the plotting.
subplot(2,2,2)
xlim([1 200])
0 Commenti
Più risposte (1)
Peter Perkins
il 4 Mar 2022
Inigo, I don't know what you data look like or how you have them stored, but I strongly recommend that you look at using a timetable and stackedplot:
tt = array2timetable(rand(5,6),"VariableNames",["A1" "A2" "A3" "B1" "B2" "B3"],"RowTimes",datetime(2022,3,1:5))
stackedplot(tt,{["A1" "A2" "A3"] ["B1" "B2" "B3"]})
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/914889/image.png)
Vedere anche
Categorie
Scopri di più su Subplots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!