【问题标题】:Resizing 3D scatter plot调整 3D 散点图的大小
【发布时间】:2016-08-21 09:48:09
【问题描述】:

我设法使用 Spyder (Python 3.5) 绘制了一个 3D 图形。但是,图的大小太小了。如何增加图表的大小以便将其保存为图像文件?

以下是用于绘制图形的代码:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt



fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

x =[0,1,2,3,4]
y =[11,1,5,2,9]
z =[1,2,3,4,5,6]



ax.scatter(x, y, z, c='r', marker='o')

ax.set_xlabel('Days since last interaction')
ax.set_ylabel('Number of conversions')
ax.set_zlabel('Total number of interactions')

plt.show()

谢谢!

【问题讨论】:

    标签: python matplotlib image-resizing spyder scatter3d


    【解决方案1】:

    您可以在创建图形时使用命名参数figsize

    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    
    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(111, projection='3d')
    
    x =[0, 1, 2, 3, 4, 0]
    y =[11, 1, 5, 2, 9, 0]
    z =[1, 2, 3, 4, 5, 6]  # this array contained one value too many. (I padded the other two arrays)
    
    ax.scatter(x, y, z, c='r', marker='o')
    
    ax.set_xlabel('Days since last interaction')
    ax.set_ylabel('Number of conversions')
    ax.set_zlabel('Total number of interactions')
    
    plt.show()
    

    【讨论】:

    • 这行得通。非常感谢 Reblochon 的帮助!
    猜你喜欢
    • 2016-03-07
    • 2018-10-27
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    • 2019-11-23
    • 2022-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多