python画柱状图 画折线图

    # 画柱状图
    plt.bar(x_labels, grid)

    画折线图
    """
    for i in range(len(grid)-1):
        plt.plot([x_labels[i],x_labels[i+1]],[grid[i],grid[i]],color = 'b')
        plt.plot([x_labels[i],x_labels[i]],[0,grid[i]],'--',color = 'b')
        plt.plot([x_labels[i+1],x_labels[i+1]],[0,grid[i]],'--',color = 'b')
    """

   公共部分
    plt.xlabel('x_labels')
    plt.ylabel('y_labels')
    plt.title("Plotting in Python demonstration")

    plt.show()

发布了94 篇原创文章 · 获赞 81 · 访问量 160万+

猜你喜欢

转载自blog.csdn.net/studyvcmfc/article/details/104020166