图列要求
#导入模块
import numpy as np
import matplotlib.pyplot as plt
#设置中文黑体
plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
# 1.准备数据
l=['周一','周二','周三','周四','周五','周六','周日',]
x_data = np.array(l)
y_data = [44.98, 45.02, 44.32, 41.05, 42.08, 42.08, 42.08] # 周末休市
# 2.创建画布和坐标系
fig=plt.figure()
ax=fig.add_axes((0.2,0.2,0.5,0.5))
# 3.绘图
ax.plot(x_data,y_data,'mo-',markersize='10')
ax.set_ylabel('收盘价(¥)',rotation=0,fontsize=13,labelpad=40)
ax.set_xlabel('周期日',fontsize=13)
# 4.定制刻度
ax.tick_params(direction='in',length=8,width=2)
plt.xticks(rotation=45) #设置X轴标签倾斜度
# 5.隐藏上轴脊和右轴脊
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
# 7.展示图表
plt.show()
运行结果