Back

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

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

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

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...