python - Seanborn:在 scatterplor 上绘制第三个变量
问题描述
我有一个按条件过滤的数据框:
df2 = df[['longitude', 'latitude', 'price']]
df_Scatter = df2[df2['price']>150]
df_Scatter 现在显示为:
longitude latitude price
1 4.89354 52.36509 236
6 4.84838 52.35132 219
7 4.88321 52.37891 160
8 4.88932 52.37537 211
13 4.86103 52.36266 250
... ... ... ...
18482 4.87564 52.37167 176
18496 4.88266 52.37398 250
18516 4.92186 52.35830 275
18517 4.91443 52.36978 330
18518 4.87967 52.36404 350
6288 rows × 3 columns
我想绘制longitude
和latitude
作为坐标和编码:价格到绘图的大小和颜色。
这就是我到目前为止所拥有的。
plt.scatter(df_Scatter.longitude, df_Scatter.latitude, c=df_Scatter.price, s = df_Scatter.price)
plt.show()
返回两个错误
AttributeError: 'int' object has no attribute 'sqrt'
TypeError: loop of ufunc does not support argument 0 of type int which has no callable sqrt method
和一个空图,其中轴范围为 0-1。
是否由于数据类型的不同而返回以下错误? 我瞄准的示例图在其图表上有一个图例,其中当编码为图的颜色和大小时,价格仍为 INT 格式。
解决方案
推荐阅读
- javascript - 在 React componentDidUpdate 中添加和组合数据
- project-reactor - 如何在同一个通量上执行两个操作
- angular - Angular 最佳实践在哪里放置更改状态的字符串
- java - 你能在那个类中有一个类的实例吗?
- google-docs - Integromat - 将 Google Doc 保存到 Airtable 附件字段
- javascript - React-Router:以编程方式从根元素路由到路由
- c# - 如何为某些端点编写自定义预检查中间件?
- javascript - 反应:在光标处插入值
- regex - 正则表达式仅保留主题标签
- java - 如何在不使用 pdfBox 裁剪数据的情况下将 pdf 调整为 LETTER 大小?