- 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 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 Articles
- How to create a dashed line that passes through Y = 1 in base R?
- Plot the points $(3, 5)$ and $(-1, 3)$ on a graph paper and verify that the straight line passing through these points also passes through the point $(1, 4)$.
- How to create a plot with dashed regression line in base R?
- How to create plot in R with different shape of points?
- How to create two line charts in the same plot in R?
- How to create an exponential distribution plot in R?
- How to create a vertical line in a time series plot in base R?\n
- How to create a line chart in R using plot function with larger width?
- How Light passes through an object?
- How to create an empty plot using ggplot2 in R?
- How to create a staircase plot in R?
- Check if a line passes through the origin in C++
- 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