1.用python第三方库绘制sinx函数图像
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
#plt.plot(x,y,s)
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,2*np.pi,50)
y = np.sin(x)
plt.title('3101')
plt.plot(x,y,'r+')
plt.show()
2.绘制饼状图
import matplotlib.pyplot as plt
labels = ['数学','专业课','英语','政治']
sizes = [40,40,10,10] #每一块的比例
colors =['yellowgreen','gold','lightskyblue','lightcoral'] #每一块的颜色
explode = (0.2,0.1,0,0) #突出显示
plt.pie(sizes,explode=explode,labels=labels,colors=colors,autopct='%1.1f%%',shadow=True,startangle=90)
plt.axis('equal') #显示为圆,避免压缩成椭圆
plt.title('3101')
3.绘制箱型图
x = np.random.randn(1000)
D= pd.DataFrame([x,x+1]).T #构造两列的DataFrame
D.plot(kind='box') #Series内置绘图方法,指定参数为box
plt.title('3101')
#用annotate添加注释
plt.show()
标签:plt,title,python,explode,colors,绘图,np From: https://www.cnblogs.com/quanshi/p/17157694.html