1、颜色的自定义记忆顺序的自定义,以及设置数据的特定顺序
col= c("#9357a9", "#ef5b09", "#ecec79")
Xxy[[32]] <- factor(Xxy[[32]], levels = c("U", "M", "D"), ordered = TRUE) #有序排序
2、应用
pwylypj = ggplot(ly1) +
geom_boxplot(aes(x = ly1[[13]], y = ly1[[8]],fill=ly1[[11]]),
size = 0.5,
width = 0.8,
color = "#000000",
##FBBC6E#FDE084#FEF9D1#EAE6D4#FBF3CB#ECDAA0#6ab04c#0bbf85???1???#AFDADC
outlier.size = 0.8,
outlier.colour = "#02B06C",
outlier.stroke = 0.8,
outlier.alpha = 0.2,
notch = F,
notchwidth = 0.5
) + scale_fill_manual(values = col) + #具体在这里--------------------
geom_smooth(aes(x = ly1[[13]], y = ly1[[8]]),method = "lm", se = TRUE, color = "#07aee3", linetype = "solid",fullrange=TRUE,fill= "#1992df",alpha=0.2)+
geom_hline(yintercept = mean(ly1[[8]]), color = "red", linetype = "dashed",size=1)+
coord_cartesian( ylim = c(0, 1000))+
scale_x_continuous(limits = c(0.5, 3.5),
breaks = c(seq(1, 3, length = 3)),
labels = xxDM,expand = c(0.1, 0.1)) +
scale_y_continuous(
limits = c(0, 1000),
breaks = c(seq(0, 1000, length = 3)),
expand = c(0, 0),
labels = waiver()
) + coord_fixed(ratio = 9 /1000) + theme(axis.line = element_line(size = 0.1,
linetype = "solid"), panel.grid.major = element_line(colour = "gray50",
size = 0.2, linetype = "dotted"), axis.text = element_text(family = "serif"),
axis.text.x = element_text(family = "serif"),
axis.text.y = element_text(family = "serif"),
panel.background = element_rect(fill = NA,
colour = "gray0", linetype = "solid"),
legend.position = "none") +labs(x = NULL, y = NULL)+
theme(panel.grid.major = element_line(size = 0.1,
linetype = "dotted")) + labs(x = NULL, y = NULL) + theme(
panel.grid.major = element_line(colour = "gray35"),
axis.ticks.length =
unit(-0.01, "cm"),
axis.text.x = element_text(margin = unit(c(0.2, 0.1, 0.1, 0.1), "cm")),
axis.text.y = element_text(margin = unit(c(0.1, 0.2, 0.1, 0.1), "cm"))
)+theme(axis.text = element_text(size = 11.5))+theme(axis.text.x= element_blank())+theme(axis.text.y= element_blank())