【发布时间】:2016-05-16 18:23:06
【问题描述】:
本质上是这个的 3d 版本:Plot two histograms at the same time with matplotlib
虽然我不知道该怎么做,因为我使用的是 Axes 3d。
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
kets = ["|00>","|01>","|10>","|11>"] #my axis labels
fig = plt.figure()
ax1 = fig.add_subplot(111,projection = '3d')
xpos = [0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3]
xpos = [i+0.25 for i in xpos]
ypos = [0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3]
ypos = [i+0.25 for i in ypos]
zpos = [0]*16
dx = 0.5*np.ones(16)
dy = 0.5*np.ones(16)
dz = [1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0]
dz2 = [0.2*i for i in dz] # to superimpose dz
ticksx = np.arange(0.5,4,1)
ticksy = np.arange(0.6,4,1)
ax1.bar3d(xpos, ypos, zpos, dx , dy ,dz, color = '#ff0080', alpha = 0.5)
ax1.w_xaxis.set_ticklabels(kets)
ax1.w_yaxis.set_ticklabels(kets)
ax1.set_zlabel('Coefficient')
plt.xticks(ticksx,kets)
plt.yticks(ticksy,kets)
plt.show()
【问题讨论】:
标签: python numpy matplotlib mplot3d