Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in R Programming by (7.3k points)
edited by

Is it possible to only set the lower bound of a limit for continuous scale? I want to make all my plots 0 based without needing to specify the upper limit bound.

e.g.

+ scale_y_continuous(minlim=0)

1 Answer

0 votes
by
edited by

To set only lower bound of a ggplot, you can use the following functions:

Using the expand_limits function:

For example:

ggplot(mtcars, aes(wt, mpg)) + geom_point() + expand_limits(y=0)

Using the  scale_y_continuous function:

ggplot(mtcars, aes(wt, mpg)) + geom_point() +

  scale_y_continuous(limits = c(0, NA))

Using the ylim() function:

ggplot(mtcars, aes(wt, mpg)) + geom_point() +

  ylim(c(0, NA))

Output:

image

Related questions

Browse Categories

...