- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- 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

# How to create a dashed line that passes through Y = 1 in base R?

Usually, plots are created with solid lines but sometimes we need to use dashed line so that the points can represent a threshold or something critical, the main objective here is to get the attention of the reader on these points. In base R, the plots are created with plot function and we can use abline function with lty =2 to draw dashed lines.

## Example1

x<−−5:5 x [1] −5 −4 −3 −2 −1 0 1 2 3 4 5 plot(x)

## Output

## Example

abline(h=2,lty=2)

## Output

## Example

y<−rnorm(10,1,5) plot(y)

## Output

## Example

abline(h=2,lty=2)

## Example3

z<−sample(c(-10:10),10) z [1] −5 −8 4 0 8 −9 −10 6 −1 10 plot(z)

## Output

## Example

abline(h=2,lty=2)

## Output

- Related Questions & Answers
- How to create a line that passes through specified points in an R plot?
- How to create a plot with dashed regression line in base R?
- How to create a dashed horizontal line in a ggplot2 graph in R?
- How to create horizontal line for Y variable at median in base R plot?
- Check if a line passes through the origin in C++
- How to create a horizontal line in a histogram in base R?
- How to create a boxplot in base R without any axes except Y?
- How to create a plot with reversed Y-axis labels in base R?
- How to create a vertical line in a time series plot in base R?
- How to create a random vector in R that sums to 1?
- How to create bar plot in base R with different limits for Y-axis?
- How to create heatmap in base R?
- How to create a horizontal boxplot in base R?
- How to make dotted/dashed line in iOS?
- How to draw a dashed line on a Tkinter canvas?

Advertisements