Hi,
I'm trying to set fill colours of bars manually but the task is more difficult than I expected. Could you help me, please?
Many thanks,
Jakkub
library(tidyverse)
table <- tibble("value"=c(0.6, 0.3, 0.08,0.02 ),
"group"= c("Surely yes","Probably yes","Probably no", "Surely no"))
ggplot(data = table,
mapping = aes(x = reorder(group, -value), y = value,label = scales::percent(value))) +
geom_col()+
scale_y_continuous(labels=scales::percent)+
labs(title="Odhodlání jít volit", x="",y="")+
geom_text(position = position_dodge(width = .9), # move to center of bars
vjust = -0.5, # nudge above top of bar
size = 3)+
theme(panel.background = element_blank(),
axis.text.x=element_text(size=9,face="bold"),
axis.text.y=element_text(size=9, face="bold"))+
scale_fill_manual(values=c("red","grey","black","orange"))
Created on 2021-02-08 by the reprex package (v0.3.0)