- 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 line that passes through specified points in an R plot?

To create a line that passes through specified points, we first need to create the plot then using plot function then xspline function can be used to join the points with straight lines. The xspline function is specifically designed to draw curves and hence it can be also used to join points in a plot as shown in the below examples.

## Example1

> plot(rpois(10,5)) > xspline(c(4,3,1),c(7,5,2))

## Output:

## Example2

> plot(rnorm(10)) > xspline(c(4,3,1),c(0.3,-0.5,-1.5))

## Output:

- Related Questions & Answers
- How to create a dashed line that passes through Y = 1 in base R?
- Check if a line passes through the origin in C++
- How to create plot in R with different shape of points?
- How to create a plot with dashed regression line in base R?
- How to create a vertical line in a time series plot in base R?
- How to create two line charts in the same plot in R?
- How to create an exponential distribution plot in R?
- Program to find line passing through 2 Points in C++
- How to create a line chart in R using plot function with larger width?
- How to create a staircase plot in R?
- How to create an empty plot using ggplot2 in R?
- How to create a line chart using ggplot2 that touches the edge in R?
- How to create ACF plot in R?
- How to create vertical line for X variable at median in base R plot
- How to create horizontal line for Y variable at median in base R plot?

Advertisements