简体   繁体   中英

On adjusting margins in matplotlib

I am trying to minimize margins around a 1X2 figure, a figure which are two stacked subplots. I searched a lot and came up with commands like:

self.figure.subplots_adjust(left=0.01, bottom=0.01, top=0.99, right=0.99)

Which leaves a large gap on top and between the subplots. Playing with these parameters, much less understanding them was tough (things like ValueError: bottom cannot be >= top )

在此输入图像描述


My questions :

What is the command to completely minimize the margins?

What do these numbers mean, and what coordinate system does this follow (the non-standard percent thing and origin point of this coordinate system)? What are the special rules on top of this coordinate system?

Where is the exact point this command needs to be called? From experiment, I figured out it works after you create subplots. What if you need to call it repeatedly after you resize a window and need to resize the figure to fit inside?

What are the other methods of adjusting layouts, especially for a single subplot?

They're in figure coordinates: http://matplotlib.sourceforge.net/users/transforms_tutorial.html

To remove gaps between subplots, use the wspace and hspace keywords to subplots_adjust .

If you want to have things adjusted automatically, have a look at tight_layout

Gridspec: http://matplotlib.sourceforge.net/users/gridspec.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM