一周内股票数值变化的数据表
#导入库并重命名
import numpy as np
import matplotlib.pyplot as plt
# 0.设置中文黑体
plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False #不进行此步会导致除了数字字母外的文字在是占位符的同时不显现,即空白块
# 1.准备数据
#X
x_data = ['周一','周二','周三','周四','周五','周六','周日']
#Y
y_data = [44.98, 45.02, 44.32, 41.05, 42.08, 42.08, 42.08]
# 2.创建画布和坐标系
ax=plt.axes((0.2,0.2,0.5,0.5))
# 3.绘图
#maker:数据点形状
#markersize:数据点大小
ax.plot(x_data,y_data,marker='o',color='purple',markersize=12)
# 4.定制刻度
#direction:刻度方向
#length:长度;width:宽度
plt.tick_params(direction='in',length=8,width=2)
# 5.设置轴标签
#fontsize:轴标签字体大小
#labelpad:轴标签与坐标轴的距离
ax.set_xlabel('周日期',fontsize=14,labelpad=10)
#rotation:轴标签的展示方向
ax.set_xlabel('周日期',fontsize=14,labelpad=10)
ax.set_ylabel('收盘价'+r'$(¥)$',fontsize=14,rotation='horizontal',labelpad=35)
# 6.隐藏上轴脊和右轴脊
#隐藏上和右轴脊
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
# 7.展示图表
plt.show()
结果展示: