Home > Enterprise >  Problem representing data using geom point in R's ggplot 2. Is it possible to change the margin
Problem representing data using geom point in R's ggplot 2. Is it possible to change the margin

Time:11-12

I have developed the following code to represent data of the iris libary

  df<-iris
    ggplot(df, aes(x= Sepal.Length, y= Sepal.Width, colour=Species, label=Species)) 
  geom_point()  geom_text(hjust=0, vjust=0)  theme(legend.position = "none")

However, as can be seen, some of the rightmost names are clipped out of the figure. I was wondering if there is a way for me to force the end of the right axis to end at 8.5?

enter image description here

CodePudding user response:

X limits can be set explicitly with scale_x_continuous e.g. adding

scale_x_continuous(limits=c(NA, 8.5))

to your code. Setting the lower limit as NA leaves it unchanged from the default.

  • Related