1

I have three lists of data, of length 35: X, Y and Z. I do

plt.hexbin(X, Y, C=Z, gridsize=35)

to yield the following plot. How to get rid of the whites?

enter image description here

mikael
  • 2,097
  • 3
  • 18
  • 24
  • Have you checked your arrays for NaNs? – Ajean Nov 22 '14 at 01:05
  • In a nutshell, just drop the gridsize of the hexbin down a bit. Your input data appears to be on a regular grid, and the gaps are basically aliasing effects. Because the data your grid is on doesn't exactly line up with the hexbin grid, you're getting regular patterns where none of your data points fall in a bin. Making the bins a bit larger (e.g. `gridsize=25`) should fix the problem. – Joe Kington Nov 22 '14 at 01:52
  • Also, `hexbin` is really the wrong function for this. It's mean to bin data. Because your input data appears to be on a regular grid, why not display it as such? (e.g. `imshow` or `pcolormesh`, etc). – Joe Kington Nov 22 '14 at 01:53
  • I understand. However, when I do plt.pcolormesh(X, Y, C=Z) I get "TypeError: Illegal arguments to pcolormesh". What is the correct way to use it? – mikael Nov 22 '14 at 09:54
  • @Mixel - `pcolormesh` doesn't expect a keyword argument called "`C`". The function signature is `plt.pcolormesh(x, y, z)`. However, your input data is expected to be 2D and not 1D. If you have a series of "flattened" inputs, you'll need to put them back on a 2D grid. – Joe Kington Nov 22 '14 at 14:18

0 Answers0