我需要制作散点图,但我不知道该怎么做。
I need to make a scatter plot and I am not sure how to do this.
import matplotlib.pyplot as plt x = [5,7,8,7,2,17,2,9,4,11,12,9,6] y = [99,86,87,88,111,86,103,87,94,78,77,85,86] plt.scatter(x, y) plt.show()
尝试一下,如所示:https://www.w3schools.com/python/python_ml_scatterplot.asp
try that, as seen in:https://www.w3schools.com/python/python_ml_scatterplot.asp
使用 ax.scatter 代替 ax.plot。但是,您也可以以更干净的方式做到这一点,因为您将 pandas 与您的数据一起使用(我相信)您可以这样做
data.plot(x=name_of_column1, y=name_of_column2, marker="o", ls="")
Instead of ax.plot use ax.scatter. You can, however, do it in a cleaner way as well, since you're using pandas with your data (I believe) you can do
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
尝试一下,如所示:
https://www.w3schools.com/python/python_ml_scatterplot.asp
try that, as seen in:
https://www.w3schools.com/python/python_ml_scatterplot.asp
使用 ax.scatter 代替 ax.plot。但是,您也可以以更干净的方式做到这一点,因为您将 pandas 与您的数据一起使用(我相信)您可以这样做
Instead of ax.plot use ax.scatter. You can, however, do it in a cleaner way as well, since you're using pandas with your data (I believe) you can do