Matplotlib如何画下图所示的3D图

小弟现在的模型结果都有了,想画一个3D的图来比较各个模型之间的性能,但是不知道怎么画。求大佬指点。

性能比较 标题

 

设置下 plt.xticks() 和plt.yticks(), 比如官网的案例, 增加两句代码:

import matplotlib.pyplot as plt
import numpy as np

# Fixing random state for reproducibility
np.random.seed(19680801)


fig = plt.figure()
ax = fig.add_subplot(projection='3d')
x, y = np.random.rand(2, 100) * 4
hist, xedges, yedges = np.histogram2d(x, y, bins=4, range=[[0, 4], [0, 4]])

# Construct arrays for the anchor positions of the 16 bars.
xpos, ypos = np.meshgrid(xedges[:-1] + 0.25, yedges[:-1] + 0.25, indexing="ij")
xpos = xpos.ravel()
ypos = ypos.ravel()
zpos = 0

# Construct arrays with the dimensions for the 16 bars.
dx = dy = 0.5 * np.ones_like(zpos)
dz = hist.ravel()

ax.bar3d(xpos, ypos, zpos, dx, dy, dz, zsort='average')
# 添加两句
plt.xticks([0,1,2,3,4,5],['A','B','C','D','E']) 
plt.yticks([0,1,2,3,4,5],['A','B','C','D','E']) 

plt.show()

也可以试试pyechart, 效果更好

https://gallery.pyecharts.org/#/Bar3D/bar3d_punch_card

官网中3D plot的模块, 你可以参考下:

https://matplotlib.org/stable/gallery/index.html

您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!

速戳参与调研>>>https://t.csdnimg.cn/Kf0y