Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to correctly generate a 3d histogram using numpy or matplotlib built in functions in python?
    primarykey
    data
    text
    <p>This is more of a general question about 3d histogram creation in python. </p> <p>I have attempted to create a 3d histogram using the X and Y arrays in the following code</p> <pre><code>import matplotlib import pylab import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.axes3d import Axes3D from matplotlib import cm def threedhist(): X = [1, 3, 5, 8, 6, 7, 1, 2, 4, 5] Y = [3, 4, 3, 6, 5, 3, 1, 2, 3, 8] fig = pylab.figure() ax = Axes3D(fig) ax.hist([X, Y], bins=10, range=[[0, 10], [0, 10]]) plt.xlabel('X') plt.ylabel('Y') plt.zlabel('Frequency') plt.title('Histogram') plt.show() </code></pre> <p>However, I am getting the following error</p> <pre><code>Traceback (most recent call last): File "&lt;pyshell#0&gt;", line 1, in &lt;module&gt; a3dhistogram() File "C:/Users/ckiser/Desktop/Projects/Tom/Python Files/threedhistogram.py", line 24, in a3dhistogram ax.hist([X, Y], bins=10, range=[[0, 10], [0, 10]]) File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 7668, in hist m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs) File "C:\Python27\lib\site-packages\numpy\lib\function_base.py", line 169, in histogram mn, mx = [mi+0.0 for mi in range] TypeError: can only concatenate list (not "float") to list </code></pre> <p>I have tried the code with and without the "[" in the line ax.hist([X, Y], bins=10, range=[[0, 10], [0, 10]]) I have also tried the function from numpy without success H, xedges, yedges = np.histogram2d(x, y, bins = (10, 10)) Am I missing a step or a parameter? Any advice would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload