I'm stuck with a problem that's already been solved many times here, but none of the solution provided solves my problem.
I built a barplot using ggplot2 My data is stocked in an excel database, imported into R. It looks like this :
Subject_name | group | IFI
" XX " | 0, 1, 2 or 3 | 0 or 1 (= yes or no)
Example:
" XX1 " | 1 | 0
" XX2 " | 2 | 1
" XX3 " | 2 | 0
With this code :
ggplot(database) +
aes(x = group, fill = factor(IFI)) +
geom_bar(position = "fill", show.legend = F, colour = "NA", alpha = 0.4) +
scale_fill_manual(values=c(NA, "red")) +
scale_y_continuous(name = "% yes", limits=c(0,0.5),oob = rescale_none, breaks = seq(0,0.5,0.05), labels = percent_format(suffix = "%", accuracy = 1))
I printed the left barplot :
I can't find any solution to change color of the first column only (see right barplot, modified with Paint).
In scale_fill_manual(values=c())
, only two colors are accepted, but it changes the upper (here NA = no color) and lower (here red) part of the plot.