python数据可视化的图表式的美化

图表样式
maIplotlib在绘图的过得中会读取存储本地的配置文件件 matplotlirc,通过 matplotlibrc文件中的缺省配置信息指定图表的默认样式,完成图表元素样式的初始设置

import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
x = np.arange(5)
y1 = [1200, 2400, 1800, 2200, 1600]
y2 = [1050, 2100, 1300, 1600, 1340]
bar_width = 0.6
tick_label = ["家庭", "小说", "心理", "科技", "儿童"]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.bar(x, y1, bar_width, color="violet", align="center", label ="地区1")
ax.bar(x, y2, bar_width, bottom=y1, color="pink", align="center", label="地区2")
ax.set_ylabel("采购数量(本)")
ax.set_xlabel("图书种类")
ax.set_title(" 地区1和地区2对各类图书的采购情况")
ax.grid(True, axis='y', color="gray", alpha=0.2)
ax.set_xticks(x)
ax.set_xticklabels(tick_label)
ax.legend()
plt.show()

在这里插入图片描述

plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
eurcny_2017 = np.array([6.8007, 6.8007, 6.8015, 6.8015, 6.8060,  6.8060, 6.8060, 6.8036, 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值