【问题标题】:How to make scatter plot with 2 arrays?如何用2个数组制作散点图?
【发布时间】:2020-08-21 22:42:01
【问题描述】:

我必须是整数数组: pts_array 和 opp_pts_array

我想创建一个数据框然后绘制它:

dfscatter = pd.DataFrame(np.array([pts_array, opp_pts_array]), columns=['points', 'opponent points'])
dfscatter.plot.scatter(x='points', y='opponent points')

但是,它不起作用。 谁能帮我解决这个问题?

【问题讨论】:

  • 它不工作:会发生什么?

标签: python pandas dataframe matplotlib scatter-plot


【解决方案1】:
pts_array = [0, 1, 2, 3, 4]
opp_pts_array = [3, 4, 5, 6, 7]

d = {'points':pts_array,'opponent_points':opp_pts_array}
dfscatter = pd.DataFrame(d)

dfscatter.plot.scatter(x='points', y='opponent_points')

你去。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 2018-07-21
    • 1970-01-01
    • 2019-12-20
    • 1970-01-01
    • 2020-04-20
    相关资源
    最近更新 更多