'''
最近四周对比 柱状图 (单y轴)
date:时间序列 x轴数据
data: y轴数据 类型: list
name:邦名 类型: list
y_scope_start:y轴开始 类型: list
y_scope_end:y轴结束 类型: list
y_scope_interval:间距 类型: list
img_save_url:图片保存路径
'''
def show_week_histogram(date,data,name,y_scope_start,y_scope_end,y_scope_interval,img_save_url):
for i in range(len(data)):
# 设置图片宽高
plt.rcParams['figure.figsize'] = (20.0, 10.0)
# 设置保存图片分辨率
plt.rcParams['savefig.dpi'] = 200
plt.rcParams['figure.dpi'] = 200
# 解决中文乱码问题
plt.rcParams['font.sans-serif'] = ['Simhei']
# 自定义X轴 数据
labels = date
x = np.arange(len(labels)) # the label locations
# 柱状图与刻度距离
width = 0
fig, ax = plt.subplots()
# 加背景颜色 括号后面
ax = plt.subplot()
# 加入 横虚线
ax.yaxis.grid(True, linestyle='--')
plt.xticks(range(len(d
python Matplotlib 画图柱状图
最新推荐文章于 2024-04-04 15:05:51 发布