相关疑难解决方法(0)

如何抖动/躲避geom_segments使它们保持平行?

我用我的数据做了类似的事情,但是尽管透明度很高,但很难看到这些片段(我的数据的片段数比下面的例子少得多)才能看到它们的开头和结尾.

require(ggplot2)
ggplot(iris, aes(x = Petal.Length, xend = Petal.Width,
                 y = factor(Species), yend = factor(Species),
                 size = Sepal.Length)) +
    geom_segment(alpha = 0.05) + 
    geom_point(aes(shape = Species))
Run Code Online (Sandbox Code Playgroud)

碰到这个解决方案,但线条交叉.有没有办法让抖动产生与尖端点的平行线?我试过position_dodge而不是position_jitter,但它需要ymax.可以ymax集成在一起使用geom_segment吗?

ggplot(iris, aes(x = Petal.Length, xend = Petal.Width,
                 y = factor(Species), yend = factor(Species))) +
    geom_segment(position = position_jitter(height = 0.25))+
    geom_point(aes(size = Sepal.Length, shape = Species))
Run Code Online (Sandbox Code Playgroud)

plot r ggplot2

11
推荐指数
1
解决办法
3472
查看次数

标签 统计

ggplot2 ×1

plot ×1

r ×1