tags:

views:

1080

answers:

4

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  A: 

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')
Rince
Thanks for the advice. Turning on the grid provides the entire grid, is there some way to only display the x and y axis? Or at least to emphasize those two?
TimothyAWiseman
No idea how to emphasize them. But you can deemphasize the plots themselves and the axes will look greater.
Rince
That would work to make the grid stand out, but I am looking for a way to have a grid just for the 0 values. I can get close to this by plotting x = 0 and y = 0 over the same range of values as my main function, but this seems inelegant at best.
TimothyAWiseman
+1  A: 

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.

wierob
+1  A: 

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.

Casey
This provides a label on the bottom and left side, but I was trying to make the x and y axis with the origins stand out. One way I found to approximate this is to plot the functions x = 0 and y = 0, which gets close to what I want. Is there a more graceful way to do this?
TimothyAWiseman
+2  A: 

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.

nikow
Excellent, that is exactly what I need. Thank you.
TimothyAWiseman