仅将标签上的颜色添加到ggplot R的geom_text中

问题描述

我尝试只在标签加上颜色

代码有效

    ggplot(cmd2,aes(V1,V2)) + geom_point(mapping = aes(x = V1,y = V2,shape=Treatment,color=Concentration),size=2) + scale_color_gradient(low = "blue",high = "red")+
    coord_fixed() +
    geom_segment(data = vec.sp.df,aes(x = 0,xend = V1,y = 0,yend = V2),arrow = arrow(length = unit(0.01,"mm")),colour = "grey") +
    geom_text(data = vec.sp.df,aes(x = V1,label = ASV),size = 3)+ 
  geom_label_repel(aes(label = Sample),size=2.5,label.size = NA,fill = NA,colour = "grey")

但是当我在geom_text上添加列表以添加颜色时,出现此错误

legend_final <- as.vector(as.character(df_legend$phylum))

    ggplot(cmd2,high = "red")+
        coord_fixed() +
        geom_segment(data = vec.sp.df,colour = "grey") +
        geom_text(data = vec.sp.df,label = ASV,colour = legend_final),size = 3)+ 
      geom_label_repel(aes(label = Sample),colour = "grey") 



Error

    Error: discrete value supplied to continuous scale

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)