import pandas as pd
import pymysql
import datetime
from openpyxl import load_workbook
from openpyxl.worksheet import worksheet
from openpyxl.styles import Color,Font,Alignment,PatternFill,Border,Side,Protection
from openpyxl.worksheet import filters
from pylab import mpl
from matplotlib.font_manager import FontManager, FontProperties
import matplotlib.pyplot as plt
from openpyxl.drawing.image import Image
mpl.rcParams['font.sans-serif'] = ['SimHei'] # 用来显示中文,不然会乱码
fig = plt.figure(figsize=(20,20))
plt.subplot(311) #3行,1列,第一个位置
plt.xlabel("时间")
plt.ylabel("人数")
plt.title("近30天注册人数")
plt.plot(zhuce["时间"],zhuce["人数"], color='red', marker='o', linestyle='solid')
for a,b in zip(zhuce["时间"],zhuce["人数"]):
plt.text(a, b, '%.0f' % b, ha='center', va= 'bottom',fontsize=17)
plt.xlim(zhuce["时间"].min(), zhuce["时间"].max() )
plt.subplot(312)
plt.xlabel("时间")
plt.ylabel("人数")
plt.title("近30天登录人数")
plt.plot( denglu["时间"],denglu["人数"],color='red', marker='o', linestyle='solid')
for a,b in zip(denglu["时间"],denglu["人数"]):
plt.text(a, b, '%.0f' % b, ha='center', va= 'bottom',fontsize=15) #标签
plt.xlim(denglu["时间"].min(), denglu["时间"].max() )
plt.subplot(313)
plt.xlabel("时间")
plt.ylabel("金额")
plt.title("近30天销售金额")
plt.plot( xiaoshou["时间"],xiaoshou["金额"],color='red', marker='o', linestyle='solid')
for a,b in zip(xiaoshou["时间"],xiaoshou["金额"]):
plt.text(a, b, '%.0f' % b, ha='center', va= 'bottom',fontsize=10)
plt.xlim(xiaoshou["时间"].min(), xiaoshou["时间"].max() )
#显示效果图
目的:给图标添加标签
横坐标显示标签