segment() function in R Language is used to draw a line segment between to particular points.
Syntax: segments(x0, y0, x1, y1)
x, y: coordinates to draw a line segment between provided points.
Returns: a line segment between given points
Example 1: To draw a single line segment
Here, x0 & y0 are starting points of the line segment and x1 & y1 are ending points of line segment .
Example 2: Modifying color, thickness & line type
Example 3: Draw multiple line segments to R Plot.
- Draw a Polygon between specified points in R Programming - polygon() Function
- Addition of more points to a Plot in R Programming - points() Function
- Draw a Quantile-Quantile Plot in R Programming - qqline() Function
- Add Color Between Two Points of Kernel Density Plot in R Programming - Using with() Function
- Plot Arrows Between Points in a Graph in R Programming - arrows() Function
- Get a List of points obtained by Interpolation in R Programming - spline() and splinefun() Function
- Create Line Curves for Specified Equations in R Programming - curve() Function
- Check if a numeric value falls between a range in R Programming - between() function
- Check if a Function is a Primitive Function in R Programming - is.primitive() Function
- Get Exclusive Elements between Two Objects in R Programming - setdiff() Function
- Check for Presence of Common Elements between Objects in R Programming - is.element() Function
- Calculate the difference between Consecutive pair of Elements of a Vector in R Programming - diff() Function
- Compute the Covariance between Two Vectors in R Programming - cov() Function
- Compute the Correlation Coefficient Value between Two Vectors in R Programming - cor() Function
- Calculate Time Difference between Dates in R Programming - difftime() Function
- Find positions of Matching Elements between Vectors in R Programming - match() Function
- Find the Difference Between Two Dates in R Programming - julian() Function
- Create a Range of Colors between the Specified Colors in R Programming - colorRampPalette() Function
- Compute Density of the Distribution Function in R Programming - dunif() Function
- Apply a Function over a List of elements in R Programming - lapply() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.