following problem: I have this dataset
df
Ch V1 V2
A a1 a2
B b1 b2
C c1 c2
....
While V1 and V2 are numerical values. I want to create a barplot with a barplot for each V1 and V2 value. The code I tried
ggplot(data = df %>% gather(Variable, No., -Ch),
aes(x = reorder(ID,-No.), y = No., fill = Variable)) +
geom_bar(stat = 'identity', position= position_dodge())+
geom_col()+
xlab("Section of industry")+
ylab("No. of occurences")+
theme_classic()+
theme(axis.text.x = element_text(angle = 45, size=1),
plot.title = element_text(hjust = 0.5),
legend.position = "top")+
ggtitle("XXX")
Even with using position= position_dodge() it only merges the both bars in one like this:
Any idea how I can seperate the or why positon_dodge() is not working? I suppose because I used the gather function before?
Another problem is, that the values of Ch are too big, so if I want to display them in a readable manner the graph "disappears". Is there a ways to show these values (maybe write the value in two lines) so that this can be displayed?
Thank you very much!