# How to remove end lines from a boxplot in 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

The default boxplot in R has straight lines that display end point(s) excluding outliers. To remove these end lines from a boxplot, we can use staplelty argument and set it to 0.

For Example, if we have a vector called X then we can create the boxplot of X by using the command given below −

boxplot(X,staplelty=0)

## Example

Following snippet creates a sample data frame −

x<-rnorm(50)
x


The following dataframe is created −

 1.07121252 1.33229928 -0.42979966 -1.40995208 0.48278802 1.26974280
 -0.18708219 -0.58137514 0.16521442 -0.43517266 -2.02958751 0.82642167
 -0.04839166 -0.18796889 -0.58046680 1.06183907 1.75152677 -0.21844277
 -1.16105995 -1.88977975 -0.96235323 0.29656000 0.23496739 0.25570062
 0.08670790 0.66332777 -1.40964394 -1.04917889 1.18508295 0.55464251
 -1.10323516 1.23891058 -0.45801561 -0.59213378 0.56396096 0.61541679
 -0.12930322 -1.39358818 -0.01933885 0.92691397 -0.94091424 1.31399699
 -0.58829131 -1.22637501 -1.34721110 -0.71175576 -1.40008529 -1.24131492
 -1.25884801 0.91932581

To create a boxplot of x on the above created data frame, add the following code to the above snippet −

x<-rnorm(50)
boxplot(x)


## Output

If you execute all the above given snippets as a single program, it generates the following Output − To create a boxplot of x without end lines on the above created data frame, add the following code to the above snippet −

x<-rnorm(50)
boxplot(x)
boxplot(x,staplelty=0)


## Output

If you execute all the above given snippets as a single program, it generates the following Output − 