
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create Horizontal Line for Y Variable at Median in Base R Plot
To create horizontal line for Y variable at median in base R plot, we can follow the below steps −
- First of all, create two vectors and plot them.
- Create the horizontal 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<-rnorm(20) y<-rnorm(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 horizontal line at median
Use abline function with h argument to create the horizontal line at median as shown below −
Example
x<-rnorm(20) y<-rnorm(20) plot(x,y) abline(h=median(y))
Output
Advertisements