Set color of the boxes in a boxplot

Solution 1:

Like Rene said it is a bit hard to help while not seeing the dataset. Looking at the given code your A contains two values you want to color individually define a vector containing those two values:

df_colors <- c("0" , "1")

hist <- ggplot(df, aes(x = A, fill = df_colors )) + 
  geom_bar() + 
  theme_minimal() + 
  ggtitle("Treatment") + theme(legend.position = "bottom", plot.title = element_text(hjust=0.5), text = element_text(size = 20)) + 
  scale_fill_manual("A", values = c("0" = "dodgerblue4", "1" = "chocolate"))

Solution 2:

Not enough code for me to know exactly what you're doing but I think if you remove:

mapping = aes(fill = "red")

it will solve your problem. A reprex would help others better understand your problem. I think instead you might need something like:

    ggplot(data = your_data) +
    geom_bar(mapping = aes(x = variable_1, y = variable_2, fill = variable_3), position = "dodge")