geom_segment中的Alpha无法正常工作

问题描述:

我在情节中尝试了一些改进,并且发现geom_segment中的alpha无法正常工作.有关最低限度的工作示例,请检查以下内容:

I was trying few refinements in my plot and encounter that alpha in geom_segment is not working properly. For minimum working example check this:

ggplot(mtcars, aes(hp, mpg)) + 
  geom_point() + 
  geom_segment(aes(x = 100, xend = 200, y = 20, yend = 20), 
  inherit.aes = FALSE, 
  size = 10, 
  alpha = 0.5, 
  color = "blue")

但是,如果将alpha更改为非常低的值(例如0.005),则0.001似乎可以工作.您只能看到从0.05到0.001的效果.

However, if you change the alpha to really low value such as 0.005, 0.001 appears working. You can only see some effect from 0.05 to 0.001.

不是alpha值应该在0到1之间线性变化还是我理解不正确?

Aren't the alpha values supposed to change in a linear manner between 0 and 1 or have I understood incorrectly?

类似这样的

# install.packages(c("tidyverse"), dependencies = TRUE)
library(tidyverse)
    ggplot(mtcars, aes(hp, mpg)) + 
      geom_point() + 
      annotate('segment', x = 100, xend = 200, y = 20, yend = 20,
    size = 10,
    alpha = 0.5,
    color = "blue")