johannesring / scitools

Automatically exported from code.google.com/p/scitools
Other
0 stars 0 forks source link

IndexError in aplotter.plot(). Very weird behaviour! #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
So far I love the aplotter.plot() function. Today I tried to use dates on the 
x-axis. Unfortunately it doesn't seem to support dates. So I then tried using 
years as simple integers:

from scitools.aplotter import plot
x = [2003,2004,2005,2006,2007]
y = [2,6,4,11,2]
plot(x,y)

This got me the following error:

File "/usr/local/lib/python2.7/dist-packages/scitools/aplotter.py", line 573, 
in plot
    r = p.plot_double(args[0],args[1],**limit_flags)
File "/usr/local/lib/python2.7/dist-packages/scitools/aplotter.py", line 501, 
in plot_double
    self.plot_labels(output_buffer, plot_data)
File "/usr/local/lib/python2.7/dist-packages/scitools/aplotter.py", line 337, 
in plot_labels
    output_buffer[x_zero_coord][min_y_coord] = "+"
IndexError: list index out of range

The weird thing is that when I make the last year (2007) a lot higher, it does 
work:

x = [2003,2004,2005,2006,8000]
y = [2,6,4,11,2]
plot(x,y)

After some trial and (a lot of) error(s) I found that the critical number is 
3725. This works:

x = [2003,2004,2005,2006,3725]
y = [2,6,4,11,2]
plot(x,y)

But this doesn't work:

x = [2003,2004,2005,2006,3724]
y = [2,6,4,11,2]
plot(x,y)

I have absolutely no idea why this error occurs below this specific number. 
Does anybody know how I could make this work?

What version of the product are you using? On what operating system?
I am running scitools version 0.9.0 with Python 2.7 on Ubuntu 12.04

Original issue reported on code.google.com by kram...@gmail.com on 22 Jun 2013 at 2:38

GoogleCodeExporter commented 9 years ago
The aplotter.py module is actually written by Imri Goldberg, 2006. The version 
in SciTools is a slightly modified version of the Goldberg's original code.

The problem seems to be that the x axis is always defined as x=0. A fix 
consisting of setting the x axis to be min(x) if x=0 is not appropriate makes 
your example work. The Mercurial version of SciTools now contains this fix.

Regards,
Hans Petter Langtangen

Original comment by h...@simula.no on 24 Jun 2013 at 4:02

GoogleCodeExporter commented 9 years ago

Original comment by johannes...@gmail.com on 24 Jun 2013 at 5:46

GoogleCodeExporter commented 9 years ago
Awesome, works like a charm!

Thanks for fixing this. I use aplotter **a lot** to have quick insights in my 
analysis work. It makes my workflow a lot quicker.

Cheers!

Original comment by kram...@gmail.com on 24 Jun 2013 at 8:18

GoogleCodeExporter commented 9 years ago
You may want to check out scitools.avplotter (ascii vertical plotter) as well. 
It plots in the vertical direction with the x axis downwards and is 
particularly useful for watching and comparing long time series in the terminal 
window.

Original comment by h...@simula.no on 24 Jun 2013 at 9:01

GoogleCodeExporter commented 9 years ago
Ah, thanks for the tip, that sounds very good. I am definitely going to check 
it out!

Original comment by kram...@gmail.com on 25 Jun 2013 at 12:49