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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

What plot function do you use?

Axis are drawn automatically by all plotting functions I've seen so far, e.g.

from pylab import *
hist(randn(10000), 100)
show()

Additionally, axis can be generated manually with the axes() function.

foo.grid(b=True) should help, but it is very raw.

If you supply any of the additional arguments it automatically assumes that b is True

For example:

foo.grid(label='My awesome grid')

The best way for me is to add vertical and horizontal lines at 0:

pylab.axvline(linewidth=0.5, color = 'k')
pylab.axhline(linewidth=0.5, color = 'k')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top