推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
lynn0977
V2EX  ›  Python

matplotlib 画的图怎么自适应窗口大小

  •  
  •   lynn0977 · Aug 20, 2020 · 6270 views
    This topic created in 2229 days ago, the information mentioned may be changed or developed.
    使用 fig = Figure(figsize=(10,16))的方式创建一个图像,当 pyQt 的窗口大小变化时,matplotlib 的图形(以及画图区域)是始终固定不变的,请教一下是否有办法让画图区域和图像大小随窗口大小变化?
    4 replies  •  2020-08-21 22:07:21 +08:00
    volvo007
        1
    volvo007  
       Aug 20, 2020
    是默认的 plt.show() 给的界面吗? 好像不限定 figsize 的话就可以自适应了?
    lynn0977
        2
    lynn0977  
    OP
       Aug 20, 2020 via Android
    @volvo007 是 pyqt 的窗口
    AmberJiang
        3
    AmberJiang  
       Aug 21, 2020
    你可以试试 fig.set_size_inches(new_size, new_size, forward=True)方法
    不行的话,你可以试试这个答主提供的自定义 widget 的方法在 pyQt 里面:
    https://stackoverflow.com/questions/44505229/pyqt-automatically-resizing-widget-picture
    necomancer
        4
    necomancer  
       Aug 21, 2020
    fig.set_tight_layout(True)
    或者 plt.tight_layout()
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2750 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:40 · PVG 20:40 · LAX 05:40 · JFK 08:40
    ♥ Do have faith in what you're doing.