标签:ever 中国 beautiful tps get pen encoding https atp
1、plt.plot(x,y)
plt.plot(x,y,format_string,**kwargs)
x轴数据,y轴数据,format_string控制曲线的格式字串
format_string 由颜色字符,风格字符,和标记字符
代码:
import requests
from bs4 import BeautifulSoup
import bs4
import matplotlib.pyplot as plt
url=‘https://www.dxsbb.com/news/6347.html‘
ulist=[]
try:
r=requests.get(url)
r.raise_for_status()
r.encoding=r.apparent_encoding
message=r.text
except:
print(‘Error!‘)
soup=BeautifulSoup(message,‘html.parser‘)
for tr in soup.find(‘tbody‘).children:
if isinstance(tr,bs4.element.Tag):
tds=tr(‘td‘)
ulist.append([tds[1].string,tds[3].string])
print(ulist)
x=[]
y=[8,8,8,7,7,7,7,7,6,6,6,5,5,4,4]
for i in range(15):
x.append(ulist[i][0])
x.reverse()
y.reverse()
plt.barh(range(len(y)),y,tick_label=x,color=‘purple‘)
plt.rcParams[‘font.sans-serif‘] = [‘STKaiTi‘]
plt.rcParams[‘axes.unicode_minus‘] = False
plt.title("中国大学排名2020")
plt.show()
数据分析
标签:ever 中国 beautiful tps get pen encoding https atp
原文地址:https://www.cnblogs.com/1234diyi/p/12864253.html