数据可视化之matplotlib实战:plt.barh()函数 绘制条形图

    科技2022-07-10  192

    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.barh(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.021, SQL: 8