Nonlinear behaviour in Matlab subplot positioning

1 view (last 30 days)
Hi there. I'm using pcolorm to plot up some geographical data, but having trouble getting the resulting 2x2 subplot matrix to behave itself.
This is the sort of thing I'm getting. The subplots are miles apart so I've been playing around with set(gca, 'Position') to get rid of white space.
This is another image I've created. Different data, but same arrangement of plots. This plot has some tweaks to 'Position' to reduce white space.
This is exactly what I want. However, when I try to apply the same tweaks to 'Position', I cannot replicate the reduced white space. Instead, by gradually ramping up plot size, and ostensibly diminishing white space, there are nonlinearities in the plotting I don't understand.
The first panel here is the default plot, with no tweaks. The second and third are the same plot but with differently sized tweaks to the 'Position' parameters. To make things clear, I've made the titles of the plots the position information after I've tweaked it.
For reference, my gcf 'PaperPosition' information is [2.1217 8.5763 16.7340 12.5506] (in metric units).
So far I've tried different versions of Matlab (my institute has several on offer), I've rearranged the loops that plot my subplots, and I've tried a wide range of custom 'Position' values based on what Matlab seems to be doing at the time. I should add that the on-screen appearance of the plots has very little to do with the printed file - that's what I'm used to with Matlab, so I don't use screen appearance as a guide.
Anyway, what am I missing in how Matlab does plots? I simply can't work out how one set of four plots (with a colour bar) does one thing, but another does not - even when you force the 'Position' and 'PaperPosition' information to be exactly the same.
Best regards,
Andrew.

Answers (1)

Steven Lord
Steven Lord on 23 Aug 2018
What you're missing is that there are multiple properties that control the position of an axes. See this page for a description and illustration of the interaction between those properties. Try setting the OuterPosition property as opposed to the Position property or try changing the ActivePositionProperty to 'position'.
  2 Comments
Andrew Yool
Andrew Yool on 24 Aug 2018
Thanks very much Steven. I haven't had a chance to test this just yet, but it sounds like the sort of "hidden variables" solution that I'm looking for. I'll report back once I've had a chance to look at this properly.
Best regards,
Andrew.
Andrew Yool
Andrew Yool on 15 Apr 2019
Hi again Steven (and anyone else who can help).
So I've now been trying this, but it doesn't seem to help me. I'm still getting the same amount of whitespace around my figures, and if I try to push things too far, I get subplots disappearing on me.
When I ask for position information on my figures, they claim to be practically touching, but there's still a huge amount of unwelcome whitespace around them. I'm wondering if this is a MappingToolbox issue, because I don't have problems whenever I'm using "normal" axes.
In the figure below, for instance, the position information for the final (2,2,4) panel is [0.5203 0.1100 0.4697 0.4412], but there appears to be a lot more whitespace around it. Experimentation with Matlab's gca, gcf, Position and PaperPosition (as well as OuterPosition) doesn't provide a resolution.
Does anyone have any suggestions? This doesn't seem like it should cause problems, but it definitely does.
Cheers,
Andrew.
ukesm1_PI_obs_mod_01.png

Sign in to comment.

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!