I was just trying to change the color of my violin plot, but it isn't working at all and the color remains the same; What is the problem?
I want to set a 'light blue' color for the first group and a 'red' color for the second group.
Here is the code:
ggplot(data = Final , mapping = aes(x = Hot_group , y = PI.dAI , fill = Hot_group)) +
geom_violin(scale = "count" , position = "dodge", trim=FALSE) +
geom_jitter(width = 0.25 , shape = 21 , color = "black") +
geom_dotplot(binaxis = "y" , binwidth = 0.005, stackdir = "center") +
labs(title = "A violin chart",
x = "The frequency",
y = "correlation") +
facet_wrap(~PSQI_group,
labeller = labeller(PSQI_group = c("0" = "No",
"1" = "Yes"))) +
stat_summary(fun = mean , geom = "point", shape = 18 , size = 2 , color = "black") +
stat_summary(fun.data = mean_sdl, geom = "errorbar", color = "black", width = 0.2 , size = 0.5) +
scale_x_discrete(labels = c("0" = "group 1",
"1" = "group 2")) +
theme(plot.title = element_text(size = 16, face = "bold"),
axis.title = element_text(size = 14),
legend.title = element_text(size = 12),
legend.text = element_text(size = 10),
legend.position = "right") +
geom_boxplot(width=0.1) +
guides(fill = guide_legend(title = "The frequency")) +
scale_fill_discrete(labels = c("group 1",
"group 2")) +
scale_color_manual(values = c("lightblue", "red")) +
theme_classic()
I'd appreciate your helps
I tried different functions, including "scale_fill_manual" and "scale_color_manual" but nothing changed
I created a similar dataset based on your code and made slight modifications to it.