点图中的偏移/抖动?图例

问题描述

我可能没有使用正确的术语,但是问题在于,当创建使用点范围和多个组的点图时,图例中定义的组是无法区分的,因为该点范围覆盖了每个组的颜色(请参见红色图中的矩形)。无论如何,有没有要删除图例中的指针范围(或其他解决方案)。

enter image description here

p <- ggplot(ToothGrowth,aes(x=dose,y=len,fill = dose)) + geom_dotplot(binaxis='y',stackdir='center',dotsize = .5,alpha = .25)

p + stat_summary(fun.data=mean_sdl,fun.args = list(mult=1),geom="pointrange",color="black",size = 1)

感谢您的时间。

解决方法

尝试一下。您可以在代码的最后部分启用show.legend = F,以便该元素不会出现在图例中。这里的代码(由于没有共享数据,没有输出显示):

library(ggplot2)
#Code
p <- ggplot(ToothGrowth,aes(x=dose,y=len,fill = dose)) + 
  geom_dotplot(binaxis='y',stackdir='center',dotsize = .5,alpha = .25)
p + stat_summary(fun.data=mean_sdl,fun.args = list(mult=1),geom="pointrange",color="black",size = 1,show.legend = F)
,

或者您可以使用guides(fill = FALSE)函数或scale_fill_discrete(guide = FALSE)

p + guides(fill = FALSE)

p + scale_fill_discrete(guide = FALSE)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...