# [Numpy-discussion] numpy histogram data

Keith Sloan keith at sloan-home.co.uk
Mon Jun 7 06:37:56 EDT 2021

```Thanks

Not sure where I get centers & edges from

##### Plot of Histogram of Stacked Counts of Red elliptical Galaxies versus
Red Shift
REMrange1 =
RedEllipticalMasses[RedEllipticalMasses[RedEllipticalMasses['uminusr']>1.8]['uminusr']
<2.0]
print(len(REMrange1))
counts1, bins1 = np.histogram(REMrange1['Z_1'],bins=bins)
REMrange2a = RedEllipticalMasses[RedEllipticalMasses['uminusr']>2.0]
REMrange2 = REMrange2a[REMrange2a['uminusr'] <2.2]
counts2, bins2 = np.histogram(REMrange2['Z_1'],bins=bins)
REMrange3a = RedEllipticalMasses[RedEllipticalMasses['uminusr']>2.2]
REMrange3 = REMrange3a[REMrange3a['uminusr'] <2.4]
counts3, bins3 = np.histogram(REMrange3['Z_1'],bins=bins)
REMrange4a = RedEllipticalMasses[RedEllipticalMasses['uminusr']>2.4]
REMrange4 = REMrange4a[REMrange4a['uminusr'] <2.6]
counts4, bins4 = np.histogram(REMrange4['Z_1'],bins=bins)
REMrange5a = RedEllipticalMasses[RedEllipticalMasses['uminusr']>2.6]
REMrange5 = REMrange5a[REMrange5a['uminusr'] <2.8]
counts5, bins5 = np.histogram(REMrange5['Z_1'],bins=bins)
counts = [counts1, counts2, counts3, counts4, counts5]
centers = [centers for _ in counts]
fig, ax = plt.subplots(1, 1, figsize=(12,8)) # make the figure with the size
10 x 8 inches
fig.suptitle("2 - Histogram Counts of Red Galaxies versus Redshift")
ax.set_xlabel('Redshift Z')
ax.set_ylabel('Counts of Galaxies')
plt.hist(centers, bins=bins, weights=counts, stacked=True)
plt.show()

Barfs on
NameError                                 Traceback (most recent call last)
<ipython-input-19-4592c1912a76> in <module>
53 counts5, bins5 = np.histogram(REMrange5['Z_1'],bins=bins)
54 counts = [counts1, counts2, counts3, counts4, counts5]
---> 55 centers = [centers for _ in counts]
56 fig, ax = plt.subplots(1, 1, figsize=(12,8)) # make the figure with
the size 10 x 8 inches
57 fig.suptitle("2 - Histogram Counts of Red Galaxies versus Redshift")

--
Sent from: http://numpy-discussion.10968.n7.nabble.com/
```