xzeroaxis

Now that you have given us axhline as a generalization of

    > gnuplot's set xzeroaxis please consider letting xticks take
    > an optional "loc" argument, which could either be "border"
    > or a number to be interpreted as a 'y' value.

    > So, e.g., axhline() xticks(arange(5),loc=0) would draw an
    > xzeroaxis and put the xtics along it.

    > Am I overlooking an obvious way to do this (in the matlab
    > module)?

Andrew Straw contacted me earlier about a related issue, that is, to
be able to offset the x axis line, ticks, and label away from the data
region, as in
Dickinson Lab.

I think this is a generally useful thing. Currently, the axes border
is drawn as a rectangle, with a facecolor and the border determined by
the rectangle edgecolor. The ticks are then placed on the rectangle
border.

The proposal is to change this behavior, so that the rectangle border
edgecolor becomes the same as the facecolor (ie invisible border).
The border is then replaced by four lines, call them bottom, top, left
and right. Each of these four lines could be placed independently in
axes coords: 0,0,1,1 = left, bottom, right, top. Eg, the bottom line
would default to

  bottom = Line2D([0,1], [0,0], transform=ax.transAxes)

ie it the x range would stretch from 0-1 (left-right) and the y coord
would be 0 (bottom) in axes coords.

To offset this line below the data range (the white rectangle defined
by the axes box) you could, for example, make the ycoord -0.1. To
place the x axes in the middle of the axes box, you would make the
ycoord 0.5.

However, there is a rub. Sometimes you probably want to place the
xaxes y location in data units, eg at y=0. Note that this is not the
same as y=0 in axes coords, which is always the bottom of the
rectangle. This is possible since matplotlib lets you specify the x
and y data in different data coordinate systems, eg with
http://matplotlib.sourceforge.net/matplotlib.transforms.html#-blend_xy_sep_transform,
but I think it would take some work to make the interface easy and
intuitive. The other trick, from the developer side, is to couple the
location of the ticks and tick labels to the y coord of the axes line.
Doable, certainly, but would require some redesign because currently
they all "know" their location.

JDH

John Hunter wrote:

"Alan" == Alan G Isaac <aisaac@...310...> writes:
           
   > Now that you have given us axhline as a generalization of
   > gnuplot's set xzeroaxis please consider letting xticks take
   > an optional "loc" argument, which could either be "border"
   > or a number to be interpreted as a 'y' value.

   > So, e.g., axhline() xticks(arange(5),loc=0) would draw an
   > xzeroaxis and put the xtics along it.

I tried your suggestion in gnuplot, and I found the results to be ugly -- the ticks straddled the axis line, rather than being inside or outside. But I see, in theory, what you mean.

However, there is a rub. Sometimes you probably want to place the
xaxes y location in data units, eg at y=0. Note that this is not the
same as y=0 in axes coords, which is always the bottom of the
rectangle. This is possible since matplotlib lets you specify the x
and y data in different data coordinate systems, eg with
http://matplotlib.sourceforge.net/matplotlib.transforms.html#-blend_xy_sep_transform,

Hmm... that URL is not working for me, but I found what you referenced at http://matplotlib.sourceforge.net/matplotlib.transforms.html

but I think it would take some work to make the interface easy and
intuitive. The other trick, from the developer side, is to couple the
location of the ticks and tick labels to the y coord of the axes line.
Doable, certainly, but would require some redesign because currently
they all "know" their location.

It seems using scipy's traits object for its ability to set observers on a variable may be useful here.

As I said earlier, I may take a stab at this, but I always feel as if I'm "hacking in the dark" when I try and grasp matplotlib's transform and render model... When/if I look at this in greater detail, I'll surely let you know! :slight_smile:

If you're going to a new render model in the future (kiva?), I wonder how useful or long-term would any changes I made now be?

Cheers!
Andrew