【问题标题】:Scatter plot in matplotlib origin alignedmatplotlib原点对齐的散点图
【发布时间】:2014-01-18 23:45:48
【问题描述】:

我在网上找遍了这个非常简单的东西,但找不到。

我有一个 (x,y) 点的列表并想要绘制它们,原点在左下角,网格标记在每个轴上显示 0,1,2,3,4...,橙色点.我该怎么做?

【问题讨论】:

    标签: python matplotlib plot


    【解决方案1】:

    相当基本,你应该看看 matplotlib 文档,examplesgallery 部分显示了很多不同的东西和生成它的代码。

    import matplotlib.pyplot as plt
    import numpy as np
    
    #Random sample data
    x = np.random.random_integers(0, 5, 10)
    y = np.random.random_integers(0, 5, 10)
    
    plt.scatter(x,y, c='orange')
    plt.ylim([0, y.max()])
    plt.xlim([0, x.max()])
    plt.grid()
    plt.show()
    

    【讨论】:

    猜你喜欢
    • 2021-10-27
    • 2014-12-28
    • 2020-07-22
    • 2013-10-17
    • 2017-09-29
    • 1970-01-01
    • 1970-01-01
    • 2013-06-29
    相关资源
    最近更新 更多