Alpha in geom_segment not working

I tried a few clarifications in my conspiracy and ran into what alphawas geom_segmentworking incorrectly. For a minimal working example, check this out:

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")

However, if you change the alpha value to a really low value, such as 0.005, 0.001 will appear. You can only see the effect from 0.05 to 0.001.

Are alpha values ​​changing linearly between 0 and 1, or am I misunderstood?

+4
source share
2 answers

Something like that,

# 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")

segment in ggplt2

+3
source

ggplot2 , , . , data ggplot . .

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

enter image description here

- , :

ggplot(mtcars) +
    geom_point(aes(hp, mpg)) +
    annotate(
      'segment',
      x = 100,
      xend = 200,
      y = 20,
      yend = 20,
      size = 10,
      colour = "blue",
      alpha = 0.5
    ) 
0

Source: https://habr.com/ru/post/1692568/


All Articles