- 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 two line charts in the same plot in R?
- How to create a staircase plot in R?
- How to create a line chart in R using plot function with larger width?
- How to create an empty plot using ggplot2 in R?
- Program to find line passing through 2 Points in C++
- How to create a plot in R with gridlines using plot function?
- How to create a plot in R with a different plot window size using plot function?
- How to create a dot plot using ggplot2 in R?
- How to create a plot with cross sign in R?
- How to create a plot using rgb colors in R?
- How to create a plot of Poisson distribution in R?

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

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.

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

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

Advertisements