I can't manage to stack plot 2 columns with the right graph size

3 次查看(过去 30 天)
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)

采纳的回答

Max Heimann
Max Heimann 2022-3-4
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])

更多回答(1 个)

Peter Perkins
Peter Perkins 2022-3-4
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"]})

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by