How to plot too many graph in a figure?

6 views (last 30 days)
Arnab Pal
Arnab Pal on 6 Jan 2021
Commented: Adam Danz on 6 Jan 2021
I am trying to plot 18 graph in a figure in 3 X 6 manner. But they are comming as too small. I want to increase length of the canvas but unable to do that properly. Please give me solutions.
I have prepared the code in this way:
figure(1)
subplot(6,3,1)
plot(0:24, DE(1,:),':o', 'MarkerSize', 4, 'MarkerFaceColor', [0.75 0 0.75],'color',[0.75 0 0.75],'LineWidth',2),legend('BES1 DE', 'Location','southeast')
set(gca,'FontSize',18)
xlabel('Hour')
ylabel('Stored Energy (kWh)')
xlim([0 24])
% ylim([2085 2105])
set(gca,'XTick',(0:6:24));
subplot(6,3,2)
plot(0:24, DE(2,:),':o', 'MarkerSize', 4, 'MarkerFaceColor',[0 0.5 0],'color',[0 0.5 0],'LineWidth',2),legend('BES2 DE', 'Location','southeast')
set(gca,'FontSize',18)
xlabel('Hour')
ylabel('Stored Energy (kWh)')
xlim([0 24])
% ylim([1000 3500])
set(gca,'XTick',(0:6:24));

Answers (2)

Cris LaPierre
Cris LaPierre on 6 Jan 2021
It looks like all your plots share the same x axis values. Have you considered using stackedplot?
  3 Comments
Cris LaPierre
Cris LaPierre on 6 Jan 2021
To make a bigger figure window, use the figure function and set the position properties. Here is an example of how you could make the figure window full screen.
figure('Units','normalized','Position',[0,0,1,1])
Adam Danz
Adam Danz on 6 Jan 2021
The problem I see in the figure is the tiny axes and the large amount of space that labels and legends consume. I don't see a problem with the figure size.
stackedplot would greatly reduce that problem, especially if you have 3 stacked plots on the same figure.

Sign in to comment.


Adam Danz
Adam Danz on 6 Jan 2021
Edited: Adam Danz on 6 Jan 2021
  • Does each line really need its own axis? Why not plot all lines together on 1 axis and just different colors or marker symbols to indicate their meaning, along with a legend?
  • Remove the legends; you don't need legends if there's only 1 line per axis.
  • You also don't need xlabel and ylabel for each plot. Instead, only label the x axis on the bottom axes and 1 y axis for each column of axes.
  • Instead of subplot() use TiledLayout and set TileSpacing and/or Padding to 'compact' or 'none'.
  • Lastly, try out stackedplot() since all of your x-axes are the same scale. See how to add more than 1 stacked plot per figure and how to link the x-axes.

Categories

Find more on Line Plots 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!