python:画折线图

import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

# 设置新宋体字体的路径
font_path = 'D:/reportlab/simsun/simsun.ttf'

# 加载新宋体字体
prop = FontProperties(fname=font_path)

"""
# 读取 xlsx 文件
df = pd.read_excel('your_excel_file.xlsx')

# 假设 xlsx 文件包含两列,一列是类别,一列是数值
categories = df['Category'].tolist()
values = df['Value'].tolist()
"""
#以上是自己的数据,可以加上这个。



categories = [1, 2, 3, 4, 5]
values = [10, 15, 13, 18, 16]
# 创建柱状图,并设置颜色
plt.plot(categories, values)

# 添加标题和标签,并使用新宋体字体
plt.title('柱状图示例', fontproperties=prop)
plt.xlabel('类别', fontproperties=prop)
plt.ylabel('数值', fontproperties=prop)

# 设置刻度字体
plt.xticks(fontproperties=prop)
plt.yticks(fontproperties=prop)

# 显示图形
plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值