class zhuxingtu:
"""一个简单的柱形图"""
def __init__(self, x, y1, y2):
self.x = x
self.y1 = y1
self.y2 = y2
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(8)
y1 = np.array([4,6,8,5,12,14,7,9])
y2 = np.array([5,7,9,11,10,13,8,14])
#设宽
bar_width = 0.3
#绘图
plt.bar(x,y1,width=bar_width)
plt.bar(x+bar_width,y2,tick_label=['a','b','c','d','e','f','g','h',],width=bar_width)
plt.show()
可视化之柱形图
于 2023-09-22 00:40:09 首次发布