Skip to content
Advertisement

Plot a bar plot by using Seaborn

I am new in data visualization. I am practicing Seaborn and I am trying to plot a barplot with this dataframe. I want the chart has 3 bars on each symbol, however, the output has only 1 bar on each symbol. May I know how to fix it?

Part of the DataFrame…

JavaScript

The code like this:

JavaScript

Output like this:

enter image description here

Advertisement

Answer

To create such a plot using seaborn, note that seaborn prefers its data in “long form”. reset_index converts the index to a regular column, and melt converts the columns to <variable, value> pairs.

JavaScript

seaborn barplot with columns in long form

The long dataframe looks like:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement