Hi, I have a dataframe as shown below
Season Phylum Assigned Yield
1 Acidobacteria 157363 High
1 Ignavibacteriae 15158 Low
1 Gemmatimonadetes 16408 High
2 Actinobacteria 143507 High
2 Chloroflexi 252391 Low
3 Cyanobacteria 172041 High
3 Firmicutes 74769 High
3 Acidobacteria 222991 Low
3 Bacteroidetes 280246 Low
Is it possible to get a stacked bar chart that look something like this?
So far, i managed to only achieve the bar chart attached below using edited dataframe(by combining the columnsββSeasonβ & ''Yield". That too with x-axis splitting the first bar (1-H) into two different stacked bars
#edited dataframe;
Phylum Assigned Yield
Acidobacteria 157363 1-H
Candidatus Rokubacteria 0 1-H
Bacteroidetes 130654 1-H
Acidobacteria 222991 1-L
Candidatus Rokubacteria 0 1-L
Bacteroidetes 280246 1-L
Ignavibacteriae 23158 1-L
Acidobacteria 270764 2-H
Bacteroidetes 174637 2-H
Ignavibacteriae 39927 2-H
Gemmatimonadetes 38810 2-H
Nitrospirae 30273 2-H
Acidobacteria 135782 2-L
Bacteroidetes 156995 2-L
Acidobacteria 188891 3-H
Candidatus Eisenbacteria 0 3-H
Ignavibacteriae 13159 3-L
Gemmatimonadetes 17595 3-L
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter, MultipleLocator
import seaborn as sns
import pandas as pd
df = pd.read_csv("./root-phylum-abundance.csv",sep='\t',header=0)
#using plotly
import plotly.express as px
fig = px.bar(df, x="Yield", y="Assigned", color="Phylum", title="Long-Form Input")
fig.show()
Help will be much appreciated. Thank you