Nonlinear behaviour in Matlab subplot positioning
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Steven Lord
2018-8-23
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'.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!