Matplotlib adjust figure margin

后端 未结 7 769
盖世英雄少女心
盖世英雄少女心 2021-01-31 15:48

The following code gives me a plot with significant margins above and below the figure. I don\'t know how to eliminate the noticeable margins. subplots_adjust does

相关标签:
7条回答
  • 2021-01-31 16:40

    After plotting your chart you can easily manipulate margins this way:

    plot_margin = 0.25
    
    x0, x1, y0, y1 = plt.axis()
    plt.axis((x0 - plot_margin,
              x1 + plot_margin,
              y0 - plot_margin,
              y1 + plot_margin))
    

    This example could be changed to the aspect ratio you want or change the margins as you really want. In other stacktoverflow posts many questions related to margins could make use of this simpler approach.

    Best regards.

    0 讨论(0)
提交回复
热议问题