栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

爬虫———图形

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

爬虫———图形

1
import numpy as np
import matplotlib.pyplot as plt

x = np.array([1,2,3,4,5,6,7,8])
y = np.array([1,4,9,16,7,11,23,18])
sizes =np.array([20,50,100,200,500,1000,60,90])
colors =np.array(["red","green","black","orange","purple","beige","cyan","magenta"])#图标颜色
#scatter方法将数据插入散点图
plt.scatter(x,y,s=sizes,c=colors)
plt.title('scatter')
plt.show()

2

import numpy as np
import matplotlib.pyplot as plt
#准备数据
ypoints=np.array([5,6,8,45,56,12,45,31,2,89])
ypoints2=np.array([5,6,8,45,56,12,45,31,2,89])*2
#数据放进图表
# plt.plot(ypoints,'o:g')
# plt.plot(ypoints,marker='o',linestyle=':',color='g')
plt.plot(ypoints,marker='o',ls=':',c='g',linewidth='2')
plt.plot(ypoints2)
#添加标题,x轴名字,y轴名字
plt.title("table")
plt.xlabel('x-label')
plt.ylabel('y-label')
#添加网格
plt.grid()
#显示
plt.show()

 3

import numpy as np
import matplotlib.pyplot as plt

ypoints=np.array([5,6,8,45,56,12,45,31,2,89])
#分配第一个表的位置,一行两列的第一个位置
plt.subplot(1,2,1)
plt.plot(ypoints,marker='o',ls=':',c='g',linewidth='2')


ypoints2=np.array([5,6,8,45,56,12,45,31,2,89])*2
#分配第一个表的位置,一行两列的第二个位置
plt.subplot(1,2,2)
plt.plot(ypoints2)

plt.show()

 4

import numpy as np
import matplotlib.pyplot as plt

#随机生成0到1之间50个数据
x = np.random.rand(50)
y = np.random.rand(50)
#指定子表位置
plt.subplot(1,2,1)#两个图形分开
plt.scatter(x,y,color='green')

#随机生成0到1之间50个数据
x2 = np.random.rand(50)
y2 = np.random.rand(50)

#指定子表位置
plt.subplot(2,2,2)#两个图形分开
plt.scatter(x2,y2,color='red')
plt.show()

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/870729.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号