matplotlib axis('tight') doesn't work?

前端 未结 2 963
离开以前
离开以前 2021-01-14 00:05

According to the documentation, ax.autoscale(tight=True) should

If True, set view limits to data limits;

With ax.ax

2条回答
  •  抹茶落季
    2021-01-14 00:53

    You're not necessarily doing anything wrong. You're using matplotlib version 2 (or greater). In this version the default plot layout was changed so that the axis had 5% padding added on to either end. Here's a link describing the plot layout: https://matplotlib.org/users/dflt_style_changes.html#plot-layout

    From the link, to change it back to the 'classic' style, use:

    mpl.rcParams['axes.autolimit_mode'] = 'round_numbers'
    mpl.rcParams['axes.xmargin'] = 0
    mpl.rcParams['axes.ymargin'] = 0
    

提交回复
热议问题