Reputation: 35
I need plotting the circular histogram in matplotlib! They should look like .
Upvotes: 1
Views: 220
Reputation:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np; np.random.seed(1)
r = np.ones(100)*0.9
phi = np.random.rand(100)*2.*np.pi
hist, xedges, yedges = np.histogram2d(r, phi, bins=25, range=[[0, 1.2], [0,2*np.pi*26./25]])
R,Phi = np.meshgrid(xedges[:-1], yedges[:-1])
X = R*np.cos(Phi)
Y = -R*np.sin(Phi)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X[(R < 0.75) | (R > 1)] = np.nan
ax.plot_surface(X,Y, hist.T, alpha=0.2)
ax.plot_wireframe(X,Y, hist.T)
plt.show()
Output:
Upvotes: 1