11

I currently have a graph that looks like this using mathplotlib graph

However the margins between where the line actually starts and the edges of the graph are unnecessary, do you know how I can get rid of the margins so 0,0 starts at the corner?

For example, I want it to look like this enter image description here

nimbyest
  • 193
  • 1
  • 2
  • 11

1 Answers1

17
plt.xlim([0, x_max])
plt.ylim([0, y_max])

You can easily get the values of (x_max, y_max) from your data.

blue_note
  • 27,712
  • 9
  • 72
  • 90
  • 6
    keyword arguments `ymin` and `xmin` might be used, this way you do not have to calculate `x_max` and `y_max`, for instance `plt.xlim(xmin=0.0)`. – Jan Kuiken Jun 06 '17 at 17:12