我用ggplot2创建了一个基本的散点图,并在y轴(左侧)添加了一个带有geom_rug的地毯,但地毯隐藏了几个点。我已经尝试了position_dodge,position_jitterdodge和hjust以移动地毯并使这些点可见,但它没有给出所需的结果。我无法将地毯移到地块的右侧,因为它也会隐藏在这里。
有没有办法在地块之外的y轴的另一侧移动地毯?
以下是一些示例代码:
data("midwest", package = "ggplot2")
ggplot(midwest, aes(x=area, y=poptotal)) + geom_point(alpha=0.8)+
geom_rug(aes(x=NULL, y=poptotal), alpha=0.8)
答案 0 :(得分:0)
我通过使用
简单地扩展x轴限制来解决问题scale_x_discrete(expand = c(0.01,0.01))