Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Create a Stacked Bar Chart | Bar Charts
Visualization in Python with matplotlib
Sectionย 2. Chapterย 4
single

single

bookCreate a Stacked Bar Chart

Swipe to show menu

Task

Swipe to start coding

You are given the same dataframe data. Your tasks are:

  1. Save data for 'MADURAI' in the madurai variable.

  2. Call .bar() function twice:

    • the first time to build bars for the new_delhi data (the 'Month' column on the x-axis and the 'Rainfall' column on the y-axis);
    • the second time to build bars for the madurai data above built ones (the same columns and order as for the new_delhi data).

    Use 'New Delhi' and 'Madurai' as the label parameters.

  3. Display the legend of the plot.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Sectionย 2. Chapterย 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt