I was using pcolor with very large numbers and a small vrange (vmax - vmin), and ran into a float to integer conversion problem. Large numbers get converted to *negative* integers by astype (see numpy thread) in colors.Colormap.__call__. I'm not sure if this is even worth fixing since almost no one would run into this problem (unless you were doing something stupid, like trying to use pcolor as a 2D zero finder :). For the error to occur, you have to set vmin/vmax values (otherwise, the data is properly normalized before converting to integers), and your data has to greatly exceed these limits. Cheers, -Tony |
#!/usr/bin/env python from __future__ import with_statement
import numpy as np import cookbook as cb vmin = 0.45 vmax = 0.55 N = 1000 with cb.stopwatch(): xa = np.random.sample((N, N)) np.putmask(xa, xa > vmax, vmax) np.putmask(xa, xa < vmin, vmin) with cb.stopwatch(): xa = np.random.sample((N, N)) np.clip(xa, vmin, vmax, out=xa)
Example of the problem: #~~~~~~~~~~~~~ import matplotlib.pyplot as plt import numpy as np cmap = plt.cm.gray cmap.set_over('r', 1.0) cmap.set_under('g', 1.0) cmap.set_bad('b', 1.0) eps = 1E-8 A = np.arange(100).reshape(10, 10) plt.pcolor(A, vmin=50, vmax=50+eps, cmap=cmap) # the plot should be about half red and half green (plus a black square) # without patch, some of the red squares are filled green plt.show() #~~~~~~~~~~~~~ |
------------------------------------------------------------------------- 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-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel