# extensive scatter plot

Discussion in 'Python' started by Johannes Korn, Nov 24, 2010.

1. ### Johannes KornGuest

Hi,

I would like to produce a scatter plot with roughly 200 mio points.
Because the points are so numerous I rather need a point density plot.

I use numpy. Right now I loop over the individual data points and make a
where query on a meshgrid.

ind = where((x_grid == x_points) & (y_grid == y_points) )
counter_grid[ind] += 1

This is really slow. I'm sure there's a better solution already out there.

Kind regards!

Johannes Korn, Nov 24, 2010

2. ### Robert KernGuest

On 11/24/10 9:12 AM, Johannes Korn wrote:
> Hi,
>
> I would like to produce a scatter plot with roughly 200 mio points.
> Because the points are so numerous I rather need a point density plot.
>
> I use numpy. Right now I loop over the individual data points and make a
> where query on a meshgrid.
>
> ind = where((x_grid == x_points)& (y_grid == y_points) )
> counter_grid[ind] += 1
>
> This is really slow. I'm sure there's a better solution already out there.
>
> Kind regards!

You will want to ask numpy questions on the numpy mailing list:

http://www.scipy.org/Mailing_Lists

If you are using a particular plotting package like matplotlib, you will want to

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

If you are doing your own plotting, you will want to use the numpy.histogram2d()
function to make a 2D histogram that can be plotted using a colormapped image.
If you are using matplotlib, try matplotlib.pyplot.hexbin().

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.hexbin

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma