1

I don't see the reason why, but the default behaviour of matplotlib plot is to have margins before and after the x-axis

enter image description here

Is there a way to fix this globally for all plots in my notebook?

nivniv
  • 3,421
  • 5
  • 33
  • 40

1 Answers1

4

Figured that out. Add this to the start of your page:

from pylab import rcParams
rcParams['axes.xmargin'] = 0
rcParams['axes.ymargin'] = 0

Apparently matplotlib default margins are set to 0.05:

#axes.xmargin        : .05  # x margin.  See `axes.Axes.margins`
#axes.ymargin        : .05  # y margin.  See `axes.Axes.margins`

So changing this value would globally change it for your plots.

nivniv
  • 3,421
  • 5
  • 33
  • 40