Hi,
As far as i understood, you just want to have the colors of the bars
in colors you want to manually fix.
this is not done within aes, but outside aes. Fill/color arguments
within aes tells ggplot to apply color palettes to different levels of
a factor.
So, the first curation is:
ggplot(df0193, aes(abv, samp)) + geom_bar(stat = 'identity',
fill=c("deepskyblue", 'red', 'deepskyblue', 'red', 'deepskyblue',
'red', 'deepskyblue')) +
labs(x= "Absorbance value", y ="Samples")
Then, if you feel like the ordering of samp is messed up, you need to
convert samp into a factor,e.g.
samp <- factor(samp, levels=rev(samp), ordered = T)
ggplot(df0193, aes(abv, samp)) + geom_bar(stat = 'identity',
fill=c("deepskyblue", 'red', 'deepskyblue', 'red', 'deepskyblue',
'red', 'deepskyblue')) +
labs(x= "Absorbance value", y ="Samples")
Notice that, with samp now coded as a factor, you can now set the fill
argument within aes:
ggplot(df0193, aes(abv, samp, fill=samp)) + geom_bar(stat = 'identity')+
labs(x= "Absorbance value", y ="Samples") +
scale_fill_manual(values=c("deepskyblue", 'red', 'deepskyblue',
'deepskyblue', 'deepskyblue',
'deepskyblue', 'deepskyblue'))
So, the way you did it first, was not working because samp wasnt a
factor. You can either choose to leave it like that, in which case you
need to give the fill argument outside of aes
OR you could recode samp as a factor, in which case you _can_ set fill
within aes.
Zitat von j0hnCathey <
jtca...@gmail.com>: