I'm currently learning about data visualization using seaborn, and I came across a problem that I couldn't find a solution to.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
So I have this data
index | col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 |
---|---|---|---|---|---|---|---|---|
1990 | 0 | 4 | 7 | 3 | 7 | 0 | 6 | 6 |
1991 | 1 | 7 | 5 | 0 | 8 | 1 | 8 | 4 |
1992 | 0 | 5 | 0 | 1 | 9 | 1 | 7 | 2 |
1993 | 2 | 7 | 0 | 0 | 6 | 1 | 2 | 7 |
1994 | 4 | 1 | 5 | 5 | 8 | 1 | 6 | 3 |
1995 | 7 | 0 | 6 | 4 | 8 | 0 | 5 | 7 |
1996 | 5 | 1 | 1 | 4 | 6 | 1 | 7 | 4 |
1997 | 0 | 4 | 7 | 5 | 5 | 1 | 8 | 5 |
1998 | 1 | 3 | 7 | 0 | 7 | 0 | 7 | 1 |
1999 | 5 | 7 | 1 | 1 | 6 | 0 | 8 | 5 |
2000 | 3 | 8 | 5 | 0 | 3 | 0 | 6 | 3 |
2001 | 6 | 0 | 4 | 1 | 7 | 1 | 2 | 7 |
I want to make barplots/histplots with col1, col2 .. col8 as one column and 1990 values as one column so like 1990;
col? | val |
---|---|
col1 | 0 |
col2 | 4 |
col3 | 7 |
col4 | 3 |
col5 | 7 |
col6 | 0 |
col7 | 6 |
col8 | 6 |
and plot them for each year from 1990 to 2001.
g = sns.FacetGrid(df, col=df.index.value_counts())
g.map(sns.histplot, df.columns)
This is the code that I've written I looked at facetgrid but could get it working for my case, any feedback is appreciated.