Wuschelbeutel Kartoffelhuhn - 4 months ago 30

Python Question

I have already populated a numpy.histogram2d with a pair of lists

`(x0,y0)`

`(x1,y1)`

`(x0,y0)`

`(x1,y1)`

The relevant and official documentation is here:

https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html

On this page I only see parameters and returns, but not functions that this object supports. How can I find all the supported functions?

Answer

`np.histogram2D`

is not an object as pointed out in the comments. It is a function that returns an array with bin values as well as two for the bin edges. Nonetheless, as long as you do not compute a normed histogram, you can simply add to the histogram with the same bins. For example, to extend the example from the `np.histogram2d`

documentation:

```
import numpy as np
x = np.random.normal(3, 1, 100)
y = np.random.normal(1, 1, 100)
xedges = [0, 1, 1.5, 3, 5]
yedges = [0, 2, 3, 4, 6]
H, xedges, yedges = np.histogram2d(x, y, bins=(xedges, yedges))
x2 = np.random.normal(3, 1, 100)
y2 = np.random.normal(1, 1, 100)
H += np.histogram2d(x2, y2, bins=(xedges, yedges))[0]
```

This will give you the added combined bin values in `H`

with bin edges `xedges`

and `yedges`

.