2

I have this df that is visualized as followed:

df = data.frame(x = -10:11,
                y = seq(-5,5.5,by=0.5),
                z = rep(c(1,2),11) )

df

ggplot(df)+aes(x=x,y=y,color=factor(z),alpha=z)+
  geom_point()+
  geom_hline(yintercept=0)+
  geom_vline(xintercept = 0)+
  theme_blank()

The output: enter image description here

I checked all similar questions but nothing has worked out to remove the alpha legend. Thanks.

Quinten
  • 35,235
  • 5
  • 20
  • 53
Anas116
  • 797
  • 2
  • 9

1 Answers1

3

You could add in alpha in aesthetics and use guides to remove it like this:

df = data.frame(x = -10:11,
                y = seq(-5,5.5,by=0.5),
                z = rep(c(1,2),11) )
library(ggplot2)

ggplot(df)+aes(x=x,y=y,color=factor(z), alpha=z)+
  geom_point()+
  geom_hline(yintercept=0)+
  geom_vline(xintercept = 0) +
  guides(alpha = "none")

Created on 2023-01-20 with reprex v2.0.2

Quinten
  • 35,235
  • 5
  • 20
  • 53