首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R ggplot2 scale_shape_manual不工作,但scale_colour_manual工作正常

R ggplot2 scale_shape_manual不工作,但scale_colour_manual工作正常
EN

Stack Overflow用户
提问于 2019-10-07 19:30:26
回答 1查看 1.6K关注 0票数 1

我想设置我的2个指示器的颜色和形状,它已经在两层中绘制。scale_color_manual工作正常,但scale_shape_manual不工作。通过有或没有这行"scale_shape_manual";结果是相同的,形状"16“(实心圆圈)被拾取?

代码语言:javascript
复制
comp_graph_1 <- ggplot() + 
  layer( mapping = aes(x=log(FV), y= msd, colour = "Reference"),   #factor(Dataset) 
  data = ref,
  stat = "identity",
  geom = "point",
  position = "identity")+ 
  layer(mapping = aes(x=log(FV), y= msd,  colour = "Target"),  #  "red" "blue"
        data = target,  #data = target[Is_Phone == 0],  
        stat = "identity",
        geom = "point",
        position = "identity")+ 
  theme(panel.background = element_rect(fill = 'white'), 
        panel.grid = element_line(colour = "grey90") , panel.ontop = FALSE)+ 
  theme(legend.justification = c(0, 0), legend.position = "bottom", 
        legend.background = element_rect(), legend.title = element_blank(), legend.key = element_rect(fill = "white"),
        legend.text = element_text(size = 9,colour = "#7F7F7F"), panel.border = element_blank(), 
        axis.line = element_line(color = "#7F7F7F"))+
  theme(plot.title = element_text(size = 16, colour = "#7F7F7F"), 
        axis.title.x = element_text(size = 11, hjust = 1, face = "bold", colour = "#7F7F7F"), 
        axis.title.y = element_text(size = 11, hjust = 1, face = "bold", colour = "#7F7F7F")) +
  ggtitle(paste0(x, " / ", y, " distribution  ")) + xlab(paste0("log ", x)) + ylab(y) +
  scale_color_manual(values = c("Reference" ="#FFC000","Target"  = "#00AEEF")) +
  scale_shape_manual(values = c("Reference" =17, "Target"  = 4)) 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-07 20:03:37

我认为当你有colour = "Target“的时候,你也需要一个shape语句,shape = "Target”和shape = "Reference“,它应该是有效的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58268708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档