How to reverse the direction of an axis?

I like to reverse the direction of y axis - from top to bottom.
Anyone to help me?
I initially thought it may be easy, but it turned out much harder to
find THE SOLUTION.
Thanks.

Daehyok Shin

In [1]:plot(arange(10))
Out[1]:[<matplotlib.lines.Line2D object at 0x908ee0c>]

In [2]:ax = gca()

In [3]:ax.set_ylim(ax.get_ylim()[::-1])
Out[3]:(9.0, 0.0)

In [4]:draw()

In [5]:

The method in line 3 should work on new and old versions of matplotlib. The basic idea is that when axis limits are set, you specify the bottom, then the top (or the right, then the left), not min and then max.

Eric

Daehyok Shin wrote:

···

I like to reverse the direction of y axis - from top to bottom.
Anyone to help me?
I initially thought it may be easy, but it turned out much harder to
find THE SOLUTION.
Thanks.

Daehyok Shin

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks for your help.
I didn't know set_ylim can the reversed limits. I am wondering if it
is not a good idea to introduce a method such as axis.set_direction().
Or, axis.set_origin().

Daehyok Shin

···

On Jan 29, 2008 5:16 PM, Eric Firing <efiring@...202...> wrote:

In [1]:plot(arange(10))
Out[1]:[<matplotlib.lines.Line2D object at 0x908ee0c>]

In [2]:ax = gca()

In [3]:ax.set_ylim(ax.get_ylim()[::-1])
Out[3]:(9.0, 0.0)

In [4]:draw()

In [5]:

The method in line 3 should work on new and old versions of matplotlib.
The basic idea is that when axis limits are set, you specify the bottom,
then the top (or the right, then the left), not min and then max.

Eric

Daehyok Shin wrote:
> I like to reverse the direction of y axis - from top to bottom.
> Anyone to help me?
> I initially thought it may be easy, but it turned out much harder to
> find THE SOLUTION.
> Thanks.
>
> Daehyok Shin
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> matplotlib-users List Signup and Options

--
Daehyok Shin, PhD
Geography Department
University of North Carolina-Chapel Hill
USA

Daehyok Shin wrote:

Thanks for your help.
I didn't know set_ylim can the reversed limits. I am wondering if it
is not a good idea to introduce a method such as axis.set_direction().
Or, axis.set_origin().

There are Axes methods invert_xaxis() and invert_yaxis() in recent versions of mpl; I don't remember who added them or when.

Eric