Reverse axis direction in Pylab

I have been trying to remember how to do this FOREVER! I’m trying to plot a sound speed profile with depth along the y-axis and sound speed along the x-axis. But if I don’t reverse axes, the depth increases up, which isn’t really very intuitive.  In Matlab, it’s pretty easy.  But how to do it in Python/Pylab?  Here’s what the plot looked like before reversing the y-axis.

Here’s the code I used to reverse the axis:

[sourcecode language=”python”]
from pylab import *

### SKIPPING SOME CODE HERE

# Plot sound speed profiles
plot(sspvector1,(depthvector1))
plot(sspvector2,(depthvector2),’r’)

# Reverse the y-axis
ax = gca()
ax.set_ylim(ax.get_ylim()[::-1])

title(‘Sound speed profiles’)
xlabel(‘Sound speed (m/s)’)
ylabel(‘Depth (m)’)
grid()
show()
[/sourcecode]

And here’s the result: