Resize a figure automatically in matplotlib

后端 未结 6 869
滥情空心
滥情空心 2021-01-31 02:05

Is there a way to automatically resize a figure to properly fit contained plots in a matplotlib/pylab image?

I\'m creating heatmap (sub)plots that differ in aspect rat

6条回答
  •  粉色の甜心
    2021-01-31 02:44

    Another way of doing this is using the matplotlib tight_layout function

    import matplotlib.pyplot as plt
    fig,(ax) = plt.subplots(figsize=(8,4), ncols=1)
    data = [0,1,2,3,4]
    ax.plot(data)
    fig.tight_layout()
    fig.show()
    

提交回复
热议问题