How to make subplot size bigger?

10 views (last 30 days)
Yejin Hong
Yejin Hong on 12 May 2022
Commented: DGM on 13 May 2022
Hi, I am trying to put 21 surf subplots in one figure but the colors are not showing because they are so small. How can I make the subplot size bigger?
This is my code;
for i=1:21
xi = linspace(1,4,100);
yi = linspace(1,5,100);
zi = xlsread('curve_interpolated.xlsx',i);
% read each excel sheet
zlim([20 100])
colormap jet
caxis([0 100])
ax = gca;
ax.XTick = 1:1:4
ax.YTick = 1:1:5
ax.ZMinorTick = 'on'
Below is how I want each subplot to be shown (colors visible), but
I'm getting this output as shown below. Also, I want one big colorbar next to all the subplots, but I am getting the colorbar next to the last subplot instead. Is there a way to fix this?
DGM on 13 May 2022
There's this example of adding a global legend to a tiledlayout(), but I don't know if the same convenience is available for colorbars.
The functionality of tiledlayout() has evolved since the version I have, so if there are such conveniences, chances are that I'm in no position to craft an example.

Sign in to comment.

Answers (1)

DGM on 12 May 2022
Disregarding subplot arrangement, the edges are obscuring the faces due to the mesh resolution.
h = surf(peaks(1000));
You might use flat shading
h = surf(peaks(1000));
shading flat
% could also set the EdgeColor property of the surf object to 'none'.
That will remove the black edges from the surface. That will prevent the edges from obscuring the colormapped height information, but the smoothness tends to make it more difficult to see subtle curvature.
Using a shorter colormap may help in that regard.
colormap(parula(16)) % a shorter colormap
h = surf(peaks(1000));
shading flat
Alternatively, you can plot the data with a reduced mesh resolution so that there are fewer edges to deal with. For such tiny plots, there is no need for an extreme excess of resolution. Graphs are representations of data for visualization, not stores of data, so discarding excess data points should be acceptable if it does not impact the visual interpretation of the information.
h = surf(peaks(50));
I know that's not a complete answer, but I think that it's likely going to be part of any complete answer. I'll let someone who is more familiar with tiledlayout() handle the rest.

Community Treasure Hunt

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

Start Hunting!