Ken Myers
Ken Myers

Reputation: 616

Major gridline at origin not showing up in matplotlib

I'm trying to figure out how to get the major gridline at y=0 to display. I have major gridlines turned on, I want the box/border turned off and I have tried manually setting the major gridlines but this has not allowed the y=0 line to display.

plt.figure(figsize=(6,3))
plt.ylim(0,1)
plt.legend(loc='best')
#plt.yticks(np.arange(0, 1.2, 0.2))
plt.grid(True, 'major', 'y')
plt.box(on=None)
plt.show()

enter image description here

Upvotes: 0

Views: 144

Answers (1)

JohanC
JohanC

Reputation: 80289

You could turn clipping off for the grid lines:

plt.gca().yaxis.get_gridlines()[0].set_clip_on(False)

resulting plot

Upvotes: 1

Related Questions