Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GGR地块2图例边界问题_R_Ggplot2_Formatting_Legend - Fatal编程技术网

GGR地块2图例边界问题

GGR地块2图例边界问题,r,ggplot2,formatting,legend,R,Ggplot2,Formatting,Legend,我知道这是次要的,但这是为了出版,会让我发疯的。P0688框的底部比其余部分薄1-2像素。我不想使边框变厚,因为这样它与条形图的其余部分不匹配 plot<- ggplot(tukey_letters, aes(x = variable, y = value.x, fill = L1)) + theme(panel.background=element_rect(fill="#ffffff", color ="#000000"), panel

我知道这是次要的,但这是为了出版,会让我发疯的。P0688框的底部比其余部分薄1-2像素。我不想使边框变厚,因为这样它与条形图的其余部分不匹配

  plot<- ggplot(tukey_letters, aes(x = variable, y = value.x, 
        fill = L1)) + 
      theme(panel.background=element_rect(fill="#ffffff", color 
      ="#000000"), panel.grid.major=element_blank(), 
    panel.grid.minor=element_blank()) +
      geom_bar(stat = "identity", position=position_dodge(),color="black")+ scale_fill_manual(values=c("#FFFFFF", "#999999"))+ guides(fill=guide_legend(title="Genotype", title.position = "left")) +
  geom_errorbar(aes(ymin=value.x-se, ymax=value.x+se), width=.1,size=.5,position=position_dodge(0.9), color="black")+
  theme(
    axis.title = element_text(size =12, face="bold"),
    axis.text = element_text(angle=30, vjust=0.5,hjust=0.6,size=8,face="bold", color="#000000"),
    axis.ticks = element_line(size = rel(1)),
    axis.ticks.length = unit(0.3, "cm"),
    legend.position = c(0.2, 0.9)
  )+
  labs(
    x="Treatment",
    y="ARI1"
  )+
  #facet_wrap(~L1)+ ## You can use face_wrap function only if you need it+
  geom_text(data =tukey_letters,
            aes(x=xpos, y=ymax+offset_asterisk,label=groups), 
           size = 4,position=position_dodge(0.9) , vjust=-0.5
 )

绘图这是由于图例键的填充行为造成的。这是一个已知的问题,请参阅此GitHub线程。还有一个修复建议在这个网站上,让我在这里展示

库(tidyverse)
ggplot(mtcars)+
aes(填充=系数(气缸),x=气缸)+
几何图形条(颜色=‘黑色’)+
辅助线(填充=辅助线\图例(title.position=“left”))+
主题(legend.key=element_-rect(color=“white”)+
图例.位置=c(0.2,0.7))

放大后,图例将如下所示:

现在让我们进行修复。


draw_key_polygon 3。寻找u/Tung的答案(目前位于顶部)。看起来,对于垂直放置的填充图例(就像您所做的),仍然存在一个小间距差异的问题(这也让我感到困扰-完全明白)。更多信息请参考。是的,我看到了。可能是因为图例.spacing.y没有改变白框和灰框之间的距离,所以我执行了错误的操作。是的-我在找到帖子之前花了很长的时间对它进行了修改,并且在特定情况下,带有填充的垂直图例有点被窃听了。:/你能切换到水平吗?:)