how do I get my axis

Okay, I've gotten this far. I have a Figure and I think I can change the formatting of the values displayed in the toolbar by setting taking the X axis and setting the function
format_xdata
to something of my own (something that computes lat/lon). Similar idea for the Y axis.

So, given my figure, how do I get the X and Y axis? All I see is gca(). But how can I get both? Using fig.get_axes() I only got 1 axis.

Anybody know?

Mathew

Hi Mathew,

2008/10/13 Mathew Yeates <myeates@…369…>

Okay, I’ve gotten this far. I have a Figure and I think I can change the

formatting of the values displayed in the toolbar by setting taking the

X axis and setting the function

format_xdata

to something of my own (something that computes lat/lon). Similar idea

for the Y axis.

So, given my figure, how do I get the X and Y axis? All I see is gca().

But how can I get both? Using fig.get_axes() I only got 1 axis.

I think this is a terminology issue: the axis objects returned by gca() or in the list returned by get_axes() incorporate both the ‘axes’ in the sense of x and y axes. With the single result of gca() you can get at both the x and y axes. For example:

import matplotlib.pyplot as plt
ax = plt.gca()
ax.set_xlims(xmin=-1)
ax.set_ylims(ymax=0)
ax.format_xdata = … # if this is how you use this bit - haven’t needed to change these myself
ax.format_ydata = …

I hope that helps,

Angus.

···

AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

Thanks Angus. I tried this out ... it works once and only once!
BTW, The correct thing to do is
res=fig.gca()
res.fmt_ydata=foo()

although, like I said, it only first for the first event. Somehow res.fmt_xdata is getting set back to None

Mathew

Angus McMorland wrote:

···

Hi Mathew,

2008/10/13 Mathew Yeates <myeates@…369… <mailto:myeates@…369…>>

Okay, I've gotten this far. I have a Figure and I think I can
change the
formatting of the values displayed in the toolbar by setting
taking the
X axis and setting the function
format_xdata
to something of my own (something that computes lat/lon). Similar idea
for the Y axis.

So, given my figure, how do I get the X and Y axis? All I see is
gca().
But how can I get both? Using fig.get_axes() I only got 1 axis.

I think this is a terminology issue: the axis objects returned by gca() or in the list returned by get_axes() incorporate both the 'axes' in the sense of x and y axes. With the single result of gca() you can get at both the x and y axes. For example:

import matplotlib.pyplot as plt
ax = plt.gca()
ax.set_xlims(xmin=-1)
ax.set_ylims(ymax=0)
ax.format_xdata = ... # if this is how you use this bit - haven't needed to change these myself
ax.format_ydata = ...

I hope that helps,

Angus.

--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

Angus pointed out that I need to do
res.fmt_xdata=foo
Duh. I was evaluating foo.

But this still doesn't work!
The default formatting operation is still called.

Mathew

Mathew Yeates wrote:

···

Thanks Angus. I tried this out ... it works once and only once!
BTW, The correct thing to do is
res=fig.gca()
res.fmt_ydata=foo()

although, like I said, it only first for the first event. Somehow res.fmt_xdata is getting set back to None

Mathew

Angus McMorland wrote:

Hi Mathew,

2008/10/13 Mathew Yeates <myeates@…369… <mailto:myeates@…369…>>

Okay, I've gotten this far. I have a Figure and I think I can
change the
formatting of the values displayed in the toolbar by setting
taking the
X axis and setting the function
format_xdata
to something of my own (something that computes lat/lon). Similar idea
for the Y axis.

So, given my figure, how do I get the X and Y axis? All I see is
gca().
But how can I get both? Using fig.get_axes() I only got 1 axis.

I think this is a terminology issue: the axis objects returned by gca() or in the list returned by get_axes() incorporate both the 'axes' in the sense of x and y axes. With the single result of gca() you can get at both the x and y axes. For example:

import matplotlib.pyplot as plt
ax = plt.gca()
ax.set_xlims(xmin=-1)
ax.set_ylims(ymax=0)
ax.format_xdata = ... # if this is how you use this bit - haven't needed to change these myself
ax.format_ydata = ...

I hope that helps,

Angus.

--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

This is the correct usage -- so if it is not working you need to post
a complete example. Perhaps you are not setting the correct Axes
instance?

JDH

···

On Mon, Oct 13, 2008 at 2:27 PM, Mathew Yeates <myeates@...369...> wrote:

Angus pointed out that I need to do
res.fmt_xdata=foo
Duh. I was evaluating foo.

But this still doesn't work!
The default formatting operation is still called.

The reason it wasn't working is that my function "foo" didn't have the right signature.fmt_xdata takes 1 argument. I have no idea why I didn't see an exception displayed.

It's working now that I have
def foo(x) pass

Mathew

John Hunter wrote:

···

On Mon, Oct 13, 2008 at 2:27 PM, Mathew Yeates <myeates@...369...> wrote:

Angus pointed out that I need to do
res.fmt_xdata=foo
Duh. I was evaluating foo.

But this still doesn't work!
The default formatting operation is still called.

This is the correct usage -- so if it is not working you need to post
a complete example. Perhaps you are not setting the correct Axes
instance?

JDH