pandas.DataFrame.plot绘制散点图

官方文档

参考博客

图1:按坐标绘制散点图

图2:设置透明度,可以看清楚高密度数据点的位置。alpha=1为不透

图3:用点的大小代表人口数量(参数s),用颜色代表价格(参数c),jet预定义颜色表(参数cmap)

housing.plot(kind="scatter",x="longitude",y="latitude")
housing.plot(kind="scatter",x="longitude",y="latitude",alpha=0.1)
housing.plot(kind="scatter",x="longitude",y="latitude",alpha=0.4,s=housing["population"]/100,label="population",c="median_house_value",cmap=plt.get_cmap("jet"),colorbar=True)
plt.legend()

猜你喜欢

转载自blog.csdn.net/qq_40949544/article/details/88222538
今日推荐