数据可视化之matplotlib实战:plt.bar()函数 绘制柱状图

    科技2022-07-10  210

    import matplotlib as mpl import matplotlib.pyplot as plt # 防止乱码 mpl.rcParams["font.sans-serif"] = ["SimHei"] mpl.rcParams["axes.unicode_minus"] = False # 生产数据 x = [1,2,3,4,5,6,7,8] y = [3,1,4,5,7,9,7,2] # 生产柱状图 plt.bar(x,y,align="center",color="c",tick_label=["q","a","c","e","r","j","b","p"],hatch="/") # 设置x,y轴标签 plt.xlabel("箱子编号") plt.ylabel("箱子重量(kg)") plt.show()

    Processed: 0.027, SQL: 8