简体   繁体   English

tight_layout()的替代方案

[英]Alternatives to tight_layout()

Calling tight_layout() in matplotlib can lead to: RunTimeError: "CGContextRef is NULL" . 在matplotlib中调用tight_layout() 会导致RunTimeError: "CGContextRef is NULL" I have suffered from this error myself with several backends (including Agg ) in MacOSX and Linux. 我自己在MacOSX和Linux中遇到了几个后端(包括Agg )的错误。

If I want to achieve the same, or hopefully close enough, effect, without running into these errors, what are my options? 如果我想达到相同的效果,或希望足够接近,效果,而不会遇到这些错误,我有什么选择?

虽然不是同一个问题,但我通过将其添加到我的脚本的开头来解决我在使用tight_layout()时遇到的问题。

matplotlib.rcParams.update({'figure.autolayout': True})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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