1·基础的折线图
import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.figure(figsize=(4,3))
plt.plot(data)
plt.show()
fig = plt.figure(figsize=(10,6))
plt.plot(zt_data['月份'],zt_data['涨停次数'],'bo-')
plt.xlabel('月份')
plt.ylabel('涨停次数')
plt.show()
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/79e6043e037b099a16a2edbca409dc26.png)
2·添加子图
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
ax1.plot(data1,color='b')
ax2.plot(data2,color='r')
ax3.plot(data3,color='r')
ax4.plot(data4,color='r')
plt.show()
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/0545e6dfa353c4303fb94c2cb060394a.png)
3·识别中文及负号
plt.rcParams['font.sans-serif'] = ['SimHei'] #设置字体 以便识别中文
# plt.rcParams['font.size'] = 24 #设置字体
plt.rcParams['axes.unicode_minus'] = False #当字体是中文的时候,显示负号
4·直方图
fig = plt.figure(figsize=(4,3))
plt.hist(data,10) #数据 和 分箱数(频数)
plt.legend('注释')
plt.grid(axis='y')
plt.title('直方图')
plt.xlabel('x轴')
plt.ylabel('y轴')
# plt.xticks() #x轴坐标
# plt.yticks() #y轴坐标
plt.show()
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f587abdb43085b8efdb3f7cd245e5692.png)
5·散点图
fig = plt.figure(figsize=(4,3))
plt.scatter(x,y) #x轴数据 和y轴数据
plt.xlabel('x轴')
plt.ylabel('y轴')
plt.show()
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/091149eb323b4677f636a09472c16a3d.png)
6·条形图
plt.rcParams['font.size'] = 20 #设置字体
fig = plt.figure(figsize=(8,5))
plt.bar(x = fz.index.values,height=fz['price'].values,width=0.5)
# plt.legend('注释')
plt.xticks(rotation=45) # x轴注释字体倾斜45度
plt.title('条形图')
plt.xlabel('x轴')
plt.ylabel('y轴')
plt.show()
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/197f33b9613f1e32e0ff25aac7f6cd17.png)
7·饼图
plt.pie(fz,autopct='%2.2f%%',shadow=True,labels=fz.index)
plt.show()
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/cf2f061dad1f015d4a12baa4b4f5bde8.png)
8·箱型图
fig = plt.figure(figsize = (4,3))
plt.boxplot(data.iloc[:-1,0])
plt.xlabel('比利时')
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/1d5a541071e37ce693a4c9af223eb649.png)
9.Seaborn柱状趋势图
import seaborn as sns
fig = plt.figure(figsize=(8,6))
sns.distplot(data2['最近消费时间'],label='最近消费时间')
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f3651894b2ef111e0fa8f4c1c6559d04.png)