How do you change the size of figures drawn with matplotlib?

后端 未结 19 3081
忘掉有多难
忘掉有多难 2020-11-21 06:01

How do you change the size of figure drawn with matplotlib?

19条回答
  •  旧时难觅i
    2020-11-21 06:47

    You can simply use (from matplotlib.figure.Figure):

    fig.set_size_inches(width,height)
    

    As of Matplotlib 2.0.0, changes to your canvas will be visible immediately, as the forward keyword defaults to True.

    If you want to just change the width or height instead of both, you can use

    fig.set_figwidth(val) or fig.set_figheight(val)

    These will also immediately update your canvas, but only in Matplotlib 2.2.0 and newer.

    For Older Versions

    You need to specify forward=True explicitly in order to live-update your canvas in versions older than what is specified above. Note that the set_figwidth and set_figheight functions don’t support the forward parameter in versions older than Matplotlib 1.5.0.

提交回复
热议问题