matplotlib issue: cannot auto-scale X axis of plop properly

matplotlib issue: cannot auto-scale X axis of plop properly
Hey everyone,

I’m fairly new to matplotlib, but have read through tons of the documentation today and have a decent understanding of it. All the auto-scaling, xlim, and x_bound stuff works fine for me with the examples, but as soon as I try to use it on my data, it’s not working for me. I’ve attached a demo script, 2 input files of data, and a PNG showing the resulting chart I get. The numbers on my Y-axis range from 7656 to 59928 (a difference of 52272) and the numbers on my X-axis range from 1.22896144017e+12 to 1.22896155012e+12 (a difference of 109950).

The plot should look like a monotonically increasing line, but the resulting plot always comes out looking like a vertical line. I realize that the plot is actually correct, the problem is the default scaling on the ouptut. The easy way to justify this to yourself is to take the line “ert = float(i)” in the script and replace it with “ert = float(i) - 1228960000000” to reduce the ert #'s to a manageable size and then everything plots very nicely. The data is all linear, not logarithmic or anything, so I don’t think writing a custom scaler is the solution.

I left commented out sections in my script of all the different methods I’ve tried to scale this thing. I’ve tried all permutations I could think of for the following functions:

matplotlib.pyplot.axes().autoscale_view(…)

matplotlib.pyplot.axes().set_xbound(…)

matplotlib.pyplot.axes().set_xlim(…)

matplotlib.pyplot.axes().set_aspect(…)

matplotlib.pyplot.axis(…)

matplotlib.pyplot.axes().set_xscale(…)

Can anyone catch what I’m doing wrong here? I’m hoping it’s just something obvious due to my unfamiliarity with the tool.

Is there any way to write my own custom autoscale algorithm?

Thanks very much for your time/help!

~Brent

PS ~ Here’s my OS info:

MacBook Pro Laptop

Mac O X 10.5.6

2.6 GHz Intel Core 2 Duo

4GB 667 MHz DDR2 SDRAM

erts.txt (8.89 KB)

matplotlib_scale_problem.png

matplotlib_scale_problem.py (1.37 KB)

samples.txt (5.29 KB)

Nash, Brent R wrote:

Hey everyone,

I'm fairly new to matplotlib, but have read through tons of the documentation today and have a decent understanding of it. All the auto-scaling, xlim, and x_bound stuff works fine for me with the examples, but as soon as I try to use it on my data, it's not working for me. I've attached a demo script, 2 input files of data, and a PNG showing the resulting chart I get. The numbers on my Y-axis range from 7656 to 59928 (a difference of 52272) and the numbers on my X-axis range from 1.22896144017e+12 to 1.22896155012e+12 (a difference of 109950).

The plot should look like a monotonically increasing line, but the resulting plot always comes out looking like a vertical line. I realize that the plot is actually correct, the problem is the default scaling on the ouptut. The easy way to justify this to yourself is to take the line "ert = float(i)" in the script and replace it with "ert = float(i) - 1228960000000" to reduce the ert #'s to a manageable size and then everything plots very nicely. The data is all linear, not logarithmic or anything, so I don't think writing a custom scaler is the solution.

After removing unused imports your script works for me with mpl from svn. Can you update your mpl to svn? Or to the newest release, if that is not what you are already using? It appears that you must be hitting a bug that has been fixed, but I have no idea what it was or when it was fixed.

Eric

···

I left commented out sections in my script of all the different methods I've tried to scale this thing. I've tried all permutations I could think of for the following functions:

matplotlib.pyplot.axes().autoscale_view(...)
matplotlib.pyplot.axes().set_xbound(...)
matplotlib.pyplot.axes().set_xlim(...)
matplotlib.pyplot.axes().set_aspect(...)
matplotlib.pyplot.axis(...)
matplotlib.pyplot.axes().set_xscale(...)

Can anyone catch what I'm doing wrong here? I'm hoping it's just something obvious due to my unfamiliarity with the tool.

Is there any way to write my own custom autoscale algorithm?

Thanks very much for your time/help!

~Brent

PS ~ Here's my OS info:

MacBook Pro Laptop
Mac O X 10.5.6
2.6 GHz Intel Core 2 Duo
4GB 667 MHz DDR2 SDRAM

------------------------------------------------------------------------

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

What version of maploltib are you using?
Your data displayed with correct scale with my installation of
matplotlib 0.98.5.2.
By the way, you're chaning the axes limit of the wrong axes.
"matplotlib.pyplot.axes()" create a new axes.

Use plt.xlim (or plt.ylim for y-limit), or use the method of the existing axes.

-JJ

···

On Thu, Feb 19, 2009 at 8:22 PM, Nash, Brent R <brent.r.nash@...369...> wrote:

Hey everyone,

I'm fairly new to matplotlib, but have read through tons of the
documentation today and have a decent understanding of it. All the
auto-scaling, xlim, and x_bound stuff works fine for me with the examples,
but as soon as I try to use it on my data, it's not working for me. I've
attached a demo script, 2 input files of data, and a PNG showing the
resulting chart I get. The numbers on my Y-axis range from 7656 to 59928 (a
difference of 52272) and the numbers on my X-axis range from
1.22896144017e+12 to 1.22896155012e+12 (a difference of 109950).

The plot should look like a monotonically increasing line, but the resulting
plot always comes out looking like a vertical line. I realize that the plot
is actually correct, the problem is the default scaling on the ouptut. The
easy way to justify this to yourself is to take the line "ert = float(i)" in
the script and replace it with "ert = float(i) - 1228960000000" to reduce
the ert #'s to a manageable size and then everything plots very nicely. The
data is all linear, not logarithmic or anything, so I don't think writing a
custom scaler is the solution.

I left commented out sections in my script of all the different methods I've
tried to scale this thing. I've tried all permutations I could think of for
the following functions:

matplotlib.pyplot.axes().autoscale_view(...)
matplotlib.pyplot.axes().set_xbound(...)
matplotlib.pyplot.axes().set_xlim(...)
matplotlib.pyplot.axes().set_aspect(...)
matplotlib.pyplot.axis(...)
matplotlib.pyplot.axes().set_xscale(...)

Can anyone catch what I'm doing wrong here? I'm hoping it's just something
obvious due to my unfamiliarity with the tool.

Is there any way to write my own custom autoscale algorithm?

Thanks very much for your time/help!

~Brent

PS ~ Here's my OS info:

MacBook Pro Laptop
Mac O X 10.5.6
2.6 GHz Intel Core 2 Duo
4GB 667 MHz DDR2 SDRAM
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks for the feedback. So strangely enough it seems to have something to
do with my installation of matplotlib or some of the other background
libraries.

I took the exact same example that I sent it and ran it on Redhat Enterprise
Linux 4 and it works just fine. My team develops on Mac OS X & Linux, but
only deploys on Linux, so this isn't a huge problem, but it'd be nice to
have it working everywhere?

Is there any definitive set of instructions for getting matplotlib to build
and install properly on Mac OS X 10.5? I had to install all of the
following on my Mac:

numpy
scipy
libpng
freetype
Fortran compiler (F95 I think)
pkgconfig
matplotlib
nose

Undoubtedly there's plenty of opportunity in there for me to mess something
up. Thanks for all the feedback so far.

~Brent

Jae-Joon Lee wrote:

···

What version of maploltib are you using?
Your data displayed with correct scale with my installation of
matplotlib 0.98.5.2.
By the way, you're chaning the axes limit of the wrong axes.
"matplotlib.pyplot.axes()" create a new axes.

Use plt.xlim (or plt.ylim for y-limit), or use the method of the existing
axes.

-JJ

On Thu, Feb 19, 2009 at 8:22 PM, Nash, Brent R > <brent.r.nash@...369...> wrote:

Hey everyone,

I'm fairly new to matplotlib, but have read through tons of the
documentation today and have a decent understanding of it. All the
auto-scaling, xlim, and x_bound stuff works fine for me with the
examples,
but as soon as I try to use it on my data, it's not working for me. I've
attached a demo script, 2 input files of data, and a PNG showing the
resulting chart I get. The numbers on my Y-axis range from 7656 to 59928
(a
difference of 52272) and the numbers on my X-axis range from
1.22896144017e+12 to 1.22896155012e+12 (a difference of 109950).

The plot should look like a monotonically increasing line, but the
resulting
plot always comes out looking like a vertical line. I realize that the
plot
is actually correct, the problem is the default scaling on the ouptut.
The
easy way to justify this to yourself is to take the line "ert = float(i)"
in
the script and replace it with "ert = float(i) - 1228960000000" to
reduce
the ert #'s to a manageable size and then everything plots very nicely.
The
data is all linear, not logarithmic or anything, so I don't think writing
a
custom scaler is the solution.

I left commented out sections in my script of all the different methods
I've
tried to scale this thing. I've tried all permutations I could think of
for
the following functions:

matplotlib.pyplot.axes().autoscale_view(...)
matplotlib.pyplot.axes().set_xbound(...)
matplotlib.pyplot.axes().set_xlim(...)
matplotlib.pyplot.axes().set_aspect(...)
matplotlib.pyplot.axis(...)
matplotlib.pyplot.axes().set_xscale(...)

Can anyone catch what I'm doing wrong here? I'm hoping it's just
something
obvious due to my unfamiliarity with the tool.

Is there any way to write my own custom autoscale algorithm?

Thanks very much for your time/help!

~Brent

PS ~ Here's my OS info:

MacBook Pro Laptop
Mac O X 10.5.6
2.6 GHz Intel Core 2 Duo
4GB 667 MHz DDR2 SDRAM
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
CA
-OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
-Strategies to boost innovation and cut costs with open source
participation
-Receive a $600 discount off the registration fee with the source code:
SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
CA
-OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
-Strategies to boost innovation and cut costs with open source
participation
-Receive a $600 discount off the registration fee with the source code:
SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/matplotlib-issue%3A-cannot-auto-scale-X-axis-of-plop-properly-tp22154005p22165604.html
Sent from the matplotlib - users mailing list archive at Nabble.com.