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 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?