How do I remove the y-axis from a Pylab-generated picture?


Question

import pylab  # matplotlib

x_list = [1,1,1,1,5,4]
y_list = [1,2,3,4,5,4]

pylab.plot(x_list, y_list, 'bo')

pylab.show()

What I want to do is remove the y-axis from the diagram, only keeping the x-axis. And adding more margin to the diagram, we can see that a lot of dots are on the edge of the canvas and don't look good.

1
7
10/7/2010 10:35:56 PM

Accepted Answer

ax = pylab.gca()
ax.yaxis.set_visible(False)
pylab.show()
14
10/7/2010 10:18:10 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon