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.
If we just want to turn either the X-axis or Y-axis off, we can use plt. xticks( ) or plt. yticks( ) method respectively.
Click anywhere in the chart for which you want to display or hide axes. This displays the Chart Tools, adding the Design, Layout, and Format tabs. On the Layout tab, in the Axes group, click Axes. Click the type of axis that you want to display or hide, and then click the options that you want.
ax. remove() is all we need. It simply removes the axis from the figure.
ax = pylab.gca()
ax.yaxis.set_visible(False)
pylab.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With