# Buggy 2D plot with ylim and large y values

Hi,

I've encountered what appears to be a bug in matplotlib-0.98.3
(Windows XP, Python 2.5). The following plot of a function with poles
displays garbage (large filled boxes instead of a curve). There's
large variation in the y values, but not so large that this shouldn't
be possible to plot correctly.

Is this problem known? Is there a workaround?

from pylab import *
x = [-2.97, -2.94, -2.91, -2.88, -2.85, -2.82, -2.79, -2.76, -2.73, -2.7,
-2.67, -2.64, -2.61, -2.58, -2.55, -2.52, -2.49, -2.46, -2.43, -2.4, -2.37,
-2.34, -2.31, -2.28, -2.25, -2.22, -2.19, -2.16, -2.13, -2.1, -2.07, -2.04,
-2.01, -1.98, -1.95, -1.92, -1.89, -1.86, -1.83, -1.8, -1.77, -1.74, -1.71,
-1.68, -1.65, -1.62, -1.59, -1.56, -1.53, -1.5, -1.47, -1.44, -1.41, -1.38,
-1.35, -1.32, -1.29,-1.26, -1.23, -1.2, -1.17, -1.14, -1.11, -1.08, -1.05,
-1.02, -0.99, -0.96, -0.93, -0.9, -0.87, -0.84, -0.81, -0.78, -0.75, -0.72,
-0.69, -0.66, -0.63, -0.6, -0.57, -0.54, -0.51, -0.48, -0.45, -0.42, -0.39,
-0.36, -0.33, -0.3, -0.27, -0.24, -0.21, -0.18, -0.15, -0.12, -0.09, -0.06,
-0.03]
y = [7.40742e+6, 462976.0, 91463.4, 28950.0, 11867.8, 5732.96, 3104.37,
1830.03, 1153.53, 768.963, 538.805, 395.968, 305.58, 248.666, 214.668,
197.843, 195.517, 207.33, 235.138, 283.525, 361.162, 483.641, 679.315,
1001.79, 1558.46, 2581.22, 4621.92, 9171.58, 21022.7, 60014.1, 249909.0,
2.34376e+6, 6.0e+8, 3.75e+7, 960013.0, 146498.0, 40995.2, 15633.9,7200.57,
3768.46, 2164.71, 1336.34, 875.104, 603.287, 436.34, 331.148, 264.559,
223.743, 201.613, 194.594, 201.594, 223.706, 264.503, 331.072, 436.244,
603.172, 874.968, 1336.19, 2164.53, 3768.26, 7200.35, 15633.7, 40994.9,
146498.0, 960013.0, 3.75e+7, 6.0e+8, 2.34376e+6, 249909.0, 60013.7,
21022.2, 9171.01, 4621.3, 2580.56, 1557.75, 1001.03, 678.491, 482.753,
360.205, 282.492, 234.022, 206.125, 194.213, 196.431, 213.137, 247.004,
303.774, 394.002, 536.66, 766.62, 1150.97, 1827.22, 3101.28, 5729.56,
11864.0, 28945.8, 91458.8, 462971.0, 7.40741e+6]
plot(x, y)
ylim([-40, 40])
show()

···

--
Fredrik

Hi,

I've encountered what appears to be a bug in matplotlib-0.98.3
(Windows XP, Python 2.5). The following plot of a function with poles
displays garbage (large filled boxes instead of a curve). There's
large variation in the y values, but not so large that this shouldn't
be possible to plot correctly.

Is this problem known? Is there a workaround?

from pylab import *
x = [-2.97, -2.94, -2.91, -2.88, -2.85, -2.82, -2.79, -2.76, -2.73, -2.7,
-2.67, -2.64, -2.61, -2.58, -2.55, -2.52, -2.49, -2.46, -2.43, -2.4, -2.37,
-2.34, -2.31, -2.28, -2.25, -2.22, -2.19, -2.16, -2.13, -2.1, -2.07, -2.04,
-2.01, -1.98, -1.95, -1.92, -1.89, -1.86, -1.83, -1.8, -1.77, -1.74, -1.71,
-1.68, -1.65, -1.62, -1.59, -1.56, -1.53, -1.5, -1.47, -1.44, -1.41, -1.38,
-1.35, -1.32, -1.29,-1.26, -1.23, -1.2, -1.17, -1.14, -1.11, -1.08, -1.05,
-1.02, -0.99, -0.96, -0.93, -0.9, -0.87, -0.84, -0.81, -0.78, -0.75, -0.72,
-0.69, -0.66, -0.63, -0.6, -0.57, -0.54, -0.51, -0.48, -0.45, -0.42, -0.39,
-0.36, -0.33, -0.3, -0.27, -0.24, -0.21, -0.18, -0.15, -0.12, -0.09, -0.06,
-0.03]
y = [7.40742e+6, 462976.0, 91463.4, 28950.0, 11867.8, 5732.96, 3104.37,
1830.03, 1153.53, 768.963, 538.805, 395.968, 305.58, 248.666, 214.668,
197.843, 195.517, 207.33, 235.138, 283.525, 361.162, 483.641, 679.315,
1001.79, 1558.46, 2581.22, 4621.92, 9171.58, 21022.7, 60014.1, 249909.0,
2.34376e+6, 6.0e+8, 3.75e+7, 960013.0, 146498.0, 40995.2, 15633.9,7200.57,
3768.46, 2164.71, 1336.34, 875.104, 603.287, 436.34, 331.148, 264.559,
223.743, 201.613, 194.594, 201.594, 223.706, 264.503, 331.072, 436.244,
603.172, 874.968, 1336.19, 2164.53, 3768.26, 7200.35, 15633.7, 40994.9,
146498.0, 960013.0, 3.75e+7, 6.0e+8, 2.34376e+6, 249909.0, 60013.7,
21022.2, 9171.01, 4621.3, 2580.56, 1557.75, 1001.03, 678.491, 482.753,
360.205, 282.492, 234.022, 206.125, 194.213, 196.431, 213.137, 247.004,
303.774, 394.002, 536.66, 766.62, 1150.97, 1827.22, 3101.28, 5729.56,
11864.0, 28945.8, 91458.8, 462971.0, 7.40741e+6]
plot(x, y)
ylim([-40, 40])
show()

I may be missing something here, but everything plots fine *if you remove the call to ylim*. Note that the minimum y value is 194.213. I wouldn't expect to see anything if none of the data is between y = -40 .. 40. Sorry if I'm overlooking something.

Best,
-Tony

···

On Sep 2, 2008, at 6:56 PM, Fredrik Johansson wrote:

--
Fredrik

-------------------------------------------------------------------------
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

Removing the call to ylim is not an acceptable solution, because this
is just a part (the problematic part) of the data I am trying to plot
(most of which fits within the ylimits). The problem also persists
when zooming out.

Fredrik

···

On Wed, Sep 3, 2008 at 6:37 AM, Tony S Yu <tonyyu@...1166...> wrote:

I may be missing something here, but everything plots fine *if you remove
the call to ylim*. Note that the minimum y value is 194.213. I wouldn't
expect to see anything if none of the data is between y = -40 .. 40. Sorry
if I'm overlooking something.

Best,
-Tony

Although I did not see the problem when I tried your example (I just
have a field of white inside the axes and not the "large filled
boxes", this does sound from your description like a bug we have seen
before, where polygon artifacts are introduced by zooming too far into
a figure. I'm pretty sure is a consequence of our creating a canvas
size in agg that overflows the max integer canvas size, because on a
big zoom we create the full figure canvas and then clip what is
outside the viewport. This is the same reason people report
exponential slowing down on repeated zooms. Both of these are the
same bu that needs to be fixed.

JDH

···

On Wed, Sep 3, 2008 at 4:25 AM, Fredrik Johansson <fredrik.johansson@...287...> wrote:

Removing the call to ylim is not an acceptable solution, because this
is just a part (the problematic part) of the data I am trying to plot
(most of which fits within the ylimits). The problem also persists
when zooming out.