ggplot scale_color_manual被忽略了

时间:2017-12-13 19:36:23

标签: r ggplot2

所以我试图将两组数据绘制到一个图上:一组(BATH geom_text)显示4个模型'测量和另一组(geom_points)显示77个不同的用户'测量。

preBATH<- monophs_allcoded %>%
filter(class == 'BATH') %>%
  group_by(user, model)%>%
  summarize(mean_pre_f1 = mean(f1_scaled_pre), mean_post_f1 = mean(f1_scaled_post), mean_pre_f2 = mean(f2_scaled_pre), mean_post_f2= mean(f2_scaled_post), model_f1 = mean(f1avg_scaledMODEL), model_f2 = mean(f2avg_scaledMODEL))%>%
  group_by(user) %>%
  ggplot() +
  geom_text(aes(x= model_f2, y = model_f1, label = 'BATH', color=model))+
  geom_point(aes(x= mean_pre_f2, y = mean_pre_f1, color =user))+
  scale_color_manual(values=allcolors)+
  guides(colour = guide_legend(ncol = 1)) +
  expand_limits(x = c(0,2000)) +
  expand_limits(y = c(0,600))  +
   xlab("Lobanov-normalized and scaled f2")+
  ylab("Lobanov-normalized and scaled f1")

preBATH <- preBATH + scale_y_reverse()
preBATH <- preBATH + scale_x_reverse()

output of ggplot preBATH

理想情况下,我希望每组测量都有两个单独的颜色美学映射。根据我收集的内容,ggplot不会允许这样做。我通过生成一组颜色并将前四个指定为我想用于模型测量的颜色(allcolors)并在此行中手动指定颜色来提出解决方法;

 scale_color_manual(values=allcolors)+

然而,ggplot似乎忽略了这个命令。我没试过scale_fill_manual但没有运气。关于我失踪的任何想法?

0 个答案:

没有答案