# How to set the range for boxplot in base R?

R ProgrammingServer Side ProgrammingProgramming

#### Artificial Intelligence : The Future Of Programming

15 Lectures 54 mins

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### C Programming from scratch- Master C Programming

Best Seller

60 Lectures 8 hours

By default, R considers the vector or the data frame column values. But if we want to set the range for boxplot in base R, we can use ylim argument within the boxplot function. For example, if we have a vector called x that contains values starting from 21 to 50 and we want to have the range in the boxplot starting from 1 to 100 then we can use the command

boxplot(x,ylim=c(1,100))

## Example

Live Demo

x<-rnorm(500,10,1)
boxplot(x)

## Example

boxplot(x,ylim=c(0,15))

## Example

boxplot(x,ylim=c(2,20))

## Output

Updated on 17-Mar-2021 06:46:24