1

I have the following graph:

    set.seed(123456)
Party1_1 <- round(rnorm(20,mean=40,sd=5),0)/100
Party1_2 <- round(rnorm(20,mean=60,sd=5),0)/100
ei.data <- as.data.frame(cbind(Party1_1,Party1_2))
ei <- ggplot(ei.data, aes(Party1_1,Party1_2))+
  geom_point()+
  theme_bw()+
  scale_y_continuous(limits = c(0, 1))+
  scale_x_continuous(limits = c(0, 1))
ei

The problem I have is that it is not strictly constricted to [0,1] but partly shows space exceeding the limit I set. How can I avoid that?

Mucteam
  • 345
  • 3
  • 12

1 Answers1

1

Just add expand=c(0,0) to your scales.

ggplot(ei.data, aes(Party1_1,Party1_2))+
  geom_point()+
  theme_bw()+
  scale_y_continuous(expand=c(0,0), limits = c(0, 1))+
  scale_x_continuous(expand=c(0,0), limits = c(0, 1))

Is this what you wanted?

enter image description here

alex_555
  • 1,092
  • 1
  • 14
  • 27