小编M.V*_*.V.的帖子

是否可以在matplotlib中叠加3-d条形图?

本质上是3d版本:使用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, …
Run Code Online (Sandbox Code Playgroud)

python numpy matplotlib mplot3d

5
推荐指数
1
解决办法
848
查看次数

标签 统计

matplotlib ×1

mplot3d ×1

numpy ×1

python ×1