PDF大小裁切网站
python 3D柱形图代码
import numpy as np
import matplotlib.colors as colors
import matplotlib.cm as cm
x = np.array(range(6),float)
y = x.copy()
xpos, ypos = np.meshgrid(x,y)
xpos = xpos.flatten()
ypos = ypos.flatten()
# ARI
z = np.array([[0.752,0.793,0.784,0.789,0.797,0.794],
[0.759,0.796,0.799,0.796,0.799,0.792],
[0.754,0.797,0.797,0.795,0.79,0.774],
[0.748,0.8,0.793,0.796,0.785,0.77],
[0.74,0.793,0.795,0.799,0.804,0.801],
[0.727,0.795,0.801,0.787,0.788,0.782]])
zpos = np.zeros_like(xpos)
dx = np.ones_like(zpos)
dy = dx.copy()
dz = z.flatten()
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
ax.set_xticks(range(6))
ax.set_xticklabels(['10','50','100','150','300','500'])
ax.set_xlabel(chr(945), labelpad = 7)
ax.set_yticks(range(6))
ax.set_yticklabels(['0.1','0.2','0.3','0.4','0.5','1'])
ax.set_ylabel(chr(955), labelpad = 7)
ax.set_zlabel("NMI", labelpad = 5)
offset = dz + np.abs(dz.min())
fracs = offset.astype(float)/offset.max()
norm = colors.Normalize(fracs.min(), fracs.max())
color_values = cm.jet(norm(fracs.tolist()))
ax.bar3d(xpos,ypos,zpos,dx,dy,dz,shade=True, color=color_values)
plt.show()