I am trying to plot two overlay bar plots over 4 different categories. My dataset looks something like:
category count_first count_second
a 15 80
b 18 50
c 12 99
d 11 30
I am trying to plot a bar plot for both count_first, as well as count second whilst perserving the bar order by count. If not ordered, I can simply plot this with dataframe.melt('category')... but I am having problems with the case, where the bars need to be ordered.
df = df.sort_values(by=['category'])
m_categories=reversed(list(df['category']))
df['category'] = pd.Categorical(df['category'],categories=m_categories, ordered=False)
print(df)
#df2 = df.melt('category') -- DOESNT work
gx = (ggplot(df)
+ geom_col(aes('category','count_first', fill="#FFCE33"),stat="identity") + theme_classic()
+ geom_col(aes('category','count_second'),stat="identity")
+ xlab("category")
+ ylab("counts")
+ theme(axis_text=element_text(size=12,angle=70),
axis_title=element_text(size=15))
)
gx.draw()
plt.show()
I cant seem to set the fill parameter for individual geom_col objects, how can this be done?