Axis lines crossing in them middle of the plot

Hi Eric,

From: Eric Firing <efiring@...2391...> - 2008-11-18 00:08
Unfortunately, the present mpl architecture does not lend itself to this
sort of flexibility with respect to axis locations. It has been on the
wish list for a long time, and it can be done manually, but to make it
an easy-to-use mpl option will take some surgery and reconstruction on
mpl's internals.

What would you recommend as the best way going about this? I'm
willing to put some work in on this. There was someone back in July
who posted some code moving in this direction, but it didn't feel like
it was the right way to do things. He didn't get any response from
the list.

--Mike

That was Tony's work, and it is a shame we didn't give him more
feedback. It is definitely an important enhancement. Sometimes the
things that are harder get marked with a "star" in my inbox, and the
things that are easier get tackled right away, and the harder things
get pushed down the queue. Which is why I encourage folks to make
gentle reminders: the silence is usually not lack of interest, but
lack of time.

You should start by taking a look at where Tony left off. I will
review his code too, and when we have both had a chance to digest it,
we can discuss a plan of attack.
http://www.nabble.com/Modifications-to-axis.py-to-allow-more-flexibility-in-positioning-axis-lines%2C-ticks%2C-etc.-td18573959.html#a18573959

Tony may be interested in contributing too. Reading over his email,
one of the things that stumped him was trying to get this done right
and maintain backwards compatibility. That is admirable, and we
should try to achieve that where possible, but I don't think it is a
requirement. This is a major feature enhancement, and is one of the
things that have kept me from releasing mpl as 1.0, so if we need some
breakage to get there we can live with it. Not too many people tweak
the axis layout, in part because there is not much to tweak. Also,
most use the Axes front end helper methods (eg ax.get_xticklabels())
which will insulate them from a reorg at the Axis layer.

There are two related problems here: one easier, one harder. We can
start with the easier one. The easy one is to have a "detachable
axis". Right now we have one on the right and one on the left for the
x-axis. We may as well generalize this to allow folks to have as many
as they want and put them whereever they want (center, offset farther
to the left, etc.). It would be nice to support a different set of
tick locators and formatters for each axis, eg you could have a left
axis in dollars and a right axis in euros. Note this is not the same
thing as having a different scale, in the sense of the two_scales
example, this is just two different formatting of the same scale. The
harder problem is supporting an arbitrary number of axis instances
each with its own transform, etc. Eg generalizing the two_scales
example. I suggest you punt on that one for now.

If you really want to keep this easy, you can forget all about the
locators and formatters and just focus on allowing the user to place
the axis lines wherever they want, using the standard Axis locator and
formatter for all the axis lines. That is probably the place to start
-- we can always try to beef it up later. That part should be fairly
easy. Another enhancement that would be nice would be to support a
TextCollection for the tick labels. Drawing the tick labels is
actually a pretty big bottleneck in the whole plot rendering time, and
since the properties are naturally homogeneous (eg the rotation, the
fontsize) we could probably save some time using a collection.

JDH

···

On Tue, Nov 18, 2008 at 4:25 AM, Mike Hansen <mhansen@...287...> wrote:

What would you recommend as the best way going about this? I'm
willing to put some work in on this. There was someone back in July
who posted some code moving in this direction, but it didn't feel like
it was the right way to do things. He didn't get any response from
the list.

I spent some time on this a while ago. And I was able to partially
implement what John described above. I'm attaching my code, but note
that it is more like a proof of the concept, than a practical code.
What it can do now is to place an axis at some arbitrary position (can
be either an axes coordinate or a data coordinate).

In brief, the code is consisted of GridHelper and AxisLine. My
intention was an Axes object has a single GridHelper instance and
multiple AxisLine instances.
I wanted to make some framework which can work with any arbitrary
transformation (for example, see
http://www.atnf.csiro.au/people/mcalabre/WCS/PGSBOX/index.html), and
this affected some of my design. I only had a partial success on this,
and then swamped by other things.

So, I'm also willing to help Mike on this. And even though Mike start
with easy things, I wish the design is flexible enough to be extended
to support an arbitrary transformation in a future.

-JJ

axis_jj4.py (12.7 KB)

···

On Tue, Nov 18, 2008 at 9:20 AM, John Hunter <jdh2358@...287...> wrote:

There are two related problems here: one easier, one harder. We can
start with the easier one. The easy one is to have a "detachable
axis". Right now we have one on the right and one on the left for the
x-axis. We may as well generalize this to allow folks to have as many
as they want and put them whereever they want (center, offset farther
to the left, etc.). It would be nice to support a different set of
tick locators and formatters for each axis, eg you could have a left
axis in dollars and a right axis in euros. Note this is not the same
thing as having a different scale, in the sense of the two_scales
example, this is just two different formatting of the same scale. The
harder problem is supporting an arbitrary number of axis instances
each with its own transform, etc. Eg generalizing the two_scales
example. I suggest you punt on that one for now.