【接口】R语言中,如何自己设置想要的颜色和数据自主排序

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())

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值