Displaying X and y axis in pylab


Question

Is there a way in pylab to display the X and Y axis? I know using grid() will display them, but it comes with numerous other lines all given the same emphasis.

1
1
8/12/2009 7:19:34 PM

Accepted Answer

It sounds like your problem has been addressed in the new Matplotlib 0.99 with the Axis spine placement feature. Take a look at the examples.

3
8/13/2009 5:47:29 PM

If you are looking to name the axis you can using the label function:

import pylab
pylab.xlabel("X")
pylab.ylabel("Y")
pylab.plot(range(10))
pylab.show()

Anyway, I'm pretty sure the x and y axis are automatically generated.

matplotlib axes documentation

If you just want an empty plot then:

pylab.plot([None], [None])

this will give you the x and y axis with both going from 0 to 1. Now if you would like to change the range of either of those then you can:

pylab.xlim(xmin=0, xmax=100)
pylab.ylim(ymin=0, ymax=100)

hope that helps.


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