温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么在Python中使用scatter方法画散点图

发布时间:2021-03-18 15:56:42 来源:亿速云 阅读:203 作者:Leah 栏目:开发技术

怎么在Python中使用scatter方法画散点图?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

具体如下:

# -*-coding:utf-8-*-
import matplotlib.pyplot as plt
y = [12, 7, 1, 2, 6, 3, 7, 5, 12, 6, 14, 10, 6, 7, 1, 2, 9, 3, 4, 4, 4, 5, 4, 6, 9, 5, \
  2, 1, 2, 1, 7, 6, 43, 15, 18, 52, 39, 53, 39, 17, 12, 10, 1, 28, 59, 20, 49, \
  44, 41, 72, 31, 40, 28, 18, 59, 50, 65, 72, 100, 100, 42, 110, 86, 76, 88, 62, 50]
print(len(y))
x = []
for i in range(0, len(y)): #x and y must be the same size
  x.append(i*5)
plt.scatter(x, y, s=16, c = 'r',marker = 'o')
#设置标题并加上轴标签
plt.title("Numbers",fontsize=12)
plt.xlabel("X", fontsize=12)
plt.ylabel("Y", fontsize=12)
#设置刻度标记的大小
plt.tick_params(axis='both',which='major',labelsize=10)
#设置每个坐标的取值范围
plt.axis([0,380,0,180])
plt.show()

怎么在Python中使用scatter方法画散点图

看完上述内容,你们掌握怎么在Python中使用scatter方法画散点图的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI