Resize a figure automatically in matplotlib

后端 未结 6 872
滥情空心
滥情空心 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:55

    just use aspect='auto' when you call imshow

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    
    X = 10*np.random.rand(5,3)
    plt.imshow(X, aspect='auto')
    

    it works even if it is just for showing and not saving

提交回复
热议问题