python 画图总结
程序员文章站
2024-03-26 13:54:53
...
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pandas import Series,DataFrame
import seaborn as sns
import sys
#sep指定分隔符,header首行是列名,读取时error_bad_lines去掉报错的行
df = pd.read_csv(sys.path[0]+'\\4.csv',encoding = "utf-8",header = 0,error_bad_lines=False,sep=',')
print(df)
#画出均值
plt.plot(df['time'],df['mean'],color='red')
#设置坐标间隔
totalSeed = df.index.tolist() #获取总行数
xticks=list(range(0,len(totalSeed),4))
xlabels=[df['time'][x] for x in xticks]
#与上面均值画在一张图上
ax1=sns.barplot(x=df['time'],y=df['finish'],data=df,color='black' )
ax1.set_title('SHH JOBS')
ax1.set_xticks(xticks)
ax1.set_xticklabels(xlabels, rotation=4)
plt.show()