Improve subplot size/spacing with many subplots in matplotlib

前端 未结 6 1743
一整个雨季
一整个雨季 2020-11-22 12:56

Very similar to this question but with the difference that my figure can be as large as it needs to be.

I need to generate a whole bunch of vertically-stacked plots

6条回答
  •  误落风尘
    2020-11-22 13:18

    Try using plt.tight_layout

    As a quick example:

    import matplotlib.pyplot as plt
    
    fig, axes = plt.subplots(nrows=4, ncols=4)
    fig.tight_layout() # Or equivalently,  "plt.tight_layout()"
    
    plt.show()
    

    Without Tight Layout

    enter image description here


    With Tight Layout enter image description here

提交回复
热议问题