Matplotlib Tutorial | How to graph a Grouped Bar Chart (Code included)

Поделиться
HTML-код
  • Опубликовано: 24 сен 2024
  • In this Matplotlib for Pyhton exercise, I will be showing how to create a grouped bar graph using the matplotlib library in Python. (It has been a long time since I create a tutorial video for matplotlib, there are quiet many terms I don't even recall. I am might have to remake the tutorial again with the same content).
    Points to take away
    - We will learn how to add data label (data label annotation)
    - We will learn how to insert custom labels for X and Y axis.
    - We will learn how to insert a legned
    Source Code:
    learndataanaly...
    About Matplotlib:
    Matplotlib is a Python data visualization library with a rich selection of charting. Although not the easiest Python library to master, but once you get comfortable using the library, you can build any types of charting and visualization possible.
    ► Buy Me a Coffee? Your support is much appreciated!
    -------------------------------------------------------------------------------------
    ☕ Paypal: www.paypal.me/...
    ☕ Venmo: @Jie-Jenn
    💸 Join Robinhood with my link and we'll both get a free stock: join.robinhood...
    ► Support my channel so I can continue making free contents
    ---------------------------------------------------------------------------------------------------------------
    🌳 Becoming a Patreon supporter: / jiejenn
    🛒 By shopping on Amazon → amzn.to/2JkGeMD
    🗓 Get updated on new Python videos → / madeinpython
    📘 More tutorial videos on my website → LearnDataAnaly...
    📺 Also check out my 2nd channel Excel channel focus on sharing Excel tips: bit.ly/3B1DjSA
    ✉ Business Inquiring: RUclips@LearnDataAnalysis.org
    #Matplotlib #Python

Комментарии • 22

  • @netnuggetts
    @netnuggetts Месяц назад

    imp_stats = ['wins','losses']
    df.groupby('Ability')[imp_stats].mean().plot(kind='bar',figsize=(10,6))
    plt.xlabel('Abilites')
    plt.ylabel('Total')
    plt.title('Wins and Looses according to Prestige')
    can this be also considered as the right way?

  • @Trapnast
    @Trapnast 4 года назад +2

    How about if i want to add the 3rd bar? should i just add something = ax.bar(indx + bar_width/2, something, bar_width, label='something') ? like the 2nd one?

  • @danielkwon3062
    @danielkwon3062 4 года назад +1

    Holy.... Thank you soooo soooo soooo soooo much My graph looks amazing :)

  • @rio40c
    @rio40c 4 года назад +1

    Fantastic! Thank you very much!

  • @youssefahmed8110
    @youssefahmed8110 4 года назад

    you are genius this was very useful thank youuuuu

  • @buiquanghuy9772
    @buiquanghuy9772 Год назад

    hi, so after groupby we have a new dataframe named dataset. How do i retrieve data about all variables in the first column ? I tried something like col1 = dataset['gender'] but it return error, while dataset['math score'] works.
    Edit: nvm found it, just add .reset_index() when grouping

  • @gabriel46567
    @gabriel46567 4 года назад

    how do i plot for example in your case math score against reading score against writing score

  • @paulchelladurai3880
    @paulchelladurai3880 4 года назад +1

    very useful. can you also let us know how do we remove the top, right and left frames in th graph?

  • @4ngusofficial
    @4ngusofficial 3 года назад

    Thank you very much!!!!!!!!!!!!!!

  • @sabbirahmed4162
    @sabbirahmed4162 4 года назад +1

    how to group 3charts in the same manner without overlapping on one another

  • @JohnSmith-ok9sn
    @JohnSmith-ok9sn 3 года назад

    Very good. Thank you

    • @jiejenn
      @jiejenn  3 года назад

      Glad my video helped.

  • @luisdavidzapatasanchezestu9402
    @luisdavidzapatasanchezestu9402 3 года назад

    groups you do by columns. how could you separate the values if they are in single column?
    for example: column GENER and the values are [female, male, bisexual, lgtbi]

    • @jiejenn
      @jiejenn  3 года назад

      Then you will need to separate the values from a single column.

  • @ramaeid3420
    @ramaeid3420 3 года назад

    how did you count the number of male and female alone without the score just the count

  • @mateuszgalski9458
    @mateuszgalski9458 4 года назад

    "Error tokenizing data. C error: Expected 1 fields in line 4, saw 2" What does it mean? i did same stuff as you...

    • @mateuszgalski9458
      @mateuszgalski9458 4 года назад

      The line 4 is: df = pd.read_csv("StudentsPerformance.csv")

    • @jiejenn
      @jiejenn  4 года назад

      Looks like there is an invisible line break somewhere in your script. Not sure I can help you in that case.

  • @oooo112211
    @oooo112211 4 года назад

    I managed to plot the graphs by modifying your code to fit my data set. However the legend cannot be created due to "No handles with labels found to put in legend". =(