I am trying to make a bar chart in which I separate a variable using two other variables using fill
in ggplot2
. However, it does not allow me to use fill
twice so at the moment I have used alpha
but it does not look good.
Is there a way I can use fill twice? Or another aesthetic parameter I can use instead of alpha
to get a better-looking graph.
My code is:
ggplot(data = s1, aes(x = Income, y = count2,
fill = Mental_Health_Prob,
alpha = Smoked_Regularly)) +
geom_bar(stat = 'identity', position = 'dodge')
And it gives me this graph: