import numpy as np
import matplotlib.pyplot as plt
# 数据
x = np.arange(4)
Bj = [52, 55, 63, 53]
Sh = [44, 66, 55, 41]
bar_width = 0.3
# 绘图 x 表示 从那里开始
plt.bar(x, Bj, bar_width)
plt.bar(x+bar_width, Sh, bar_width, align="center")
# 展示图片
plt.show()
一张图上画两种bar
import numpy as np
import matplotlib.pyplot as plt
# 数据
x = np.arange(4)
Bj = [52, 55, 63, 53]
Sh = [44, 66, 55, 41]
bar_width = 0.3
# 绘图
plt.bar(x, Bj, bar_width)
plt.bar(x, Sh, bar_width, bottom=Bj)
# 展示图片
plt.show()
叠加型
"""
默认的是竖值条形图
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
# 将全局的字体设置为黑体
matplotlib.rcParams['font.family&