Curry_warrior 2021-04-22 21:17 采纳率: 50%
浏览 65
已采纳

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

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

性能比较 标题

 

  • 写回答

4条回答 默认 最新

  • CSDN专家-Yang 2021-04-23 10:48
    关注

    设置下 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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码