import numpy as np
import matplotlib.pyplot as plt
from calendar import month_name, day_name
from matplotlib.ticker import FormatStrFormatter
plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
#设计x、y轴数据
x= np.arange(1,8)
y = [44.98, 45.02, 44.32, 41.05, 42.08, 42.08, 42.08]
#设计画布
a = plt.figure()
b = a.add_axes((0.2, 0.2, 0.5, 0.5))
b.plot(x, y, '-^',ms=6)
b.yaxis.set_major_formatter(FormatStrFormatter(r'$\yen%1.1f$'))
plt.xticks(x, day_name[0:7],rotation=20)
#刻度线
plt.tick_params(direction='in',width=2)
#隐藏上轴脊和右轴脊
b.spines['top'].set_color('none')
b.spines['right'].set_color('none')
plt.title('某股票一周的收盘价')
plt.xlabel('时间')
plt.ylabel('价格')
for a,b in zip(x,y):
plt.text(a,b,format(b,','),ha='center',va='bottom',fontsize=10)
plt.show()