I am using following code to produce a bar chart of HairEyeColor dataset:
mm = melt(HairEyeColor)
mm$hair_eye = paste(mm$Hair, mm$Eye, sep='_')
ggplot(mm)+geom_bar(aes(x=hair_eye, y=value, fill=hair_eye), stat='identity')+facet_grid(Sex~.)
I get following barchart:
I want to color each bar in 2 colors: upper half to show hair color and lower half to show eye color, as shown in a manually created bar for black hair & brown eye color below:
Also, the legend needs to be removed. How can I achieve this?
HairEyeColor dataset:
> HairEyeColor
, , Sex = Male
Eye
Hair Brown Blue Hazel Green
Black 32 11 10 3
Brown 53 50 25 15
Red 10 10 7 7
Blond 3 30 5 8
, , Sex = Female
Eye
Hair Brown Blue Hazel Green
Black 36 9 5 2
Brown 66 34 29 14
Red 16 7 7 7
Blond 4 64 5 8
See Question&Answers more detail:os