[Python] How to make bar plot of a list in Python

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list that has counts of some values and I want to make a bar plot to see the counts as bars. The list is like:

    print(lii)
    # Output
    [46, 11, 9, 20, 3, 15, 8, 63, 11, 9, 24, 3, 5, 45, 51, 2, 23, 9, 17, 1, 1, 37, 29, 6, 3, 9, 25, 5, 43]


    I want something like this plot with each list value as a bar and its value on top:

    [​IMG]

    I tried the following code but it plotted the list as a series:

    plt.figure(figsize=(30, 10))
    plt.plot(lii)
    plt.show()


    [​IMG]

    Any help is appreciated.

    Continue reading...

Compartilhe esta Página