I can't manage to stack plot 2 columns with the right graph size
5 views (last 30 days)
Show older comments
inigo aguilera
on 3 Mar 2022
Commented: inigo aguilera
on 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 Comments
Accepted Answer
Max Heimann
on 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 Comments
More Answers (1)
Peter Perkins
on 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"]})
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!