- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to create vertical line for X variable at median in base R plot

To create vertical line for X variable at median in base R plot, we can follow the below steps −

- First of all, create two vectors and plot them.
- Create the vertical line at median using abline function.

## Create the vectors and plot them

Let’s create two random vectors and plot them as shown below −

### Example

x<-sample(1:100,20) y<-sample(1:100,20) plot(x,y)

On executing, the above script generates the below output(this output will vary on your system due to randomization) −

### Output

## Create the vertical line at median

Use abline function with v argument to create the vertical line at median as shown below −

### Example

x<-sample(1:100,20) y<-sample(1:100,20) plot(x,y) abline(v=median(x))

### Output

- Related Articles
- How to create horizontal line for Y variable at median in base R plot?
- How to create a vertical line in a time series plot in base R?\n
- How to create a plot with dashed regression line in base R?
- How to create a colored box for base R plot?
- How to create a predictive linear regression line for a range of independent variable in base R?
- How to create vertical line in xyplot in R?
- How to display the superscript for a single variable in a base R plot?
- How to display superscript for X-axis title in base R plot?
- How to create empty bar plot in base R?
- How to display x-bar in base R plot?
- How to create a plot in base R with dates sequence on X-axis?
- How to create a perpendicular arrow in base R plot?
- How to create a cumulative sum plot in base R?
- How to create a plot in base R without margins?
- How to create a plot with tick marks between X-axis labels in base R?

Advertisements