matplotlib.pyplot股票折线图

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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Tin9898

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值