I can't manage to stack plot 2 columns with the right graph size
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
inigo aguilera
le 3 Mar 2022
Commenté : inigo aguilera
le 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
subplot(2,2,1)
subplot(2,2,2)
subplot(2,2,3)
subplot(2,2,4)
0 commentaires
Réponse acceptée
Max Heimann
le 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 commentaires
Plus de réponses (1)
Peter Perkins
le 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"]})
Voir également
Catégories
En savoir plus sur Subplots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!