Segments: Add Line Segments To A Plot

rdrr.io Find an R package R language docs Run R in your browser Home / R Documentation / graphics / segments: Add Line Segments to a Plot segments: Add Line Segments to a Plot
segmentsR Documentation

Add Line Segments to a Plot

Description

Draw line segments between pairs of points.

Usage

segments(x0, y0, x1 = x0, y1 = y0, col = par("fg"), lty = par("lty"), lwd = par("lwd"), ...)

Arguments

x0, y0

coordinates of points from which to draw.

x1, y1

coordinates of points to which to draw. At least one must be supplied.

col, lty, lwd

graphical parameters as in par, possibly vectors. NA values in col cause the segment to be omitted.

...

further graphical parameters (from par), such as xpd and the line characteristics lend, ljoin and lmitre.

Details

For each i, a line segment is drawn between the point (x0[i], y0[i]) and the point (x1[i], y1[i]). The coordinate vectors will be recycled to the length of the longest.

The graphical parameters col, lty and lwd can be vectors of length greater than one and will be recycled if necessary.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

See Also

arrows, polygon for slightly easier and less flexible line drawing, and lines for the usual polygons.

Examples

x <- stats::runif(12); y <- stats::rnorm(12) i <- order(x, y); x <- x[i]; y <- y[i] plot(x, y, main = "arrows(.) and segments(.)") ## draw arrows from point to point : s <- seq(length(x)-1) # one shorter than data arrows(x[s], y[s], x[s+1], y[s+1], col= 1:3) s <- s[-length(s)] segments(x[s], y[s], x[s+2], y[s+2], col= 'pink')

graphics

abline: Add Straight Lines to a Plot arrows: Add Arrows to a Plot assocplot: Association Plots axis: Add an Axis to a Plot axis.POSIXct: Date and Date-time Plotting Functions axTicks: Compute Axis Tickmark Locations barplot: Bar Plots box: Draw a Box around a Plot boxplot: Box Plots boxplot.matrix: Draw a Boxplot for each Column (Row) of a Matrix bxp: Draw Box Plots from Summaries cdplot: Conditional Density Plots clip: Set Clipping Region contour: Display Contours convertXY: Convert between Graphics Coordinate Systems coplot: Conditioning Plots curve: Draw Function Plots dotchart: Cleveland's Dot Plots filled.contour: Level (Contour) Plots fourfoldplot: Fourfold Plots frame: Create / Start a New Plot Frame graphics-defunct: Defunct Functions in Package 'graphics' graphics-package: The R Graphics Package grid: Add Grid to a Plot hist: Histograms hist.POSIXt: Histogram of a Date or Date-Time Object identify: Identify Points in a Scatter Plot image: Display a Color Image layout: Specifying Complex Plot Arrangements legend: Add Legends to Plots lines: Add Connected Line Segments to a Plot locator: Graphical Input matplot: Plot Columns of Matrices mosaicplot: Mosaic Plots mtext: Write Text into the Margins of a Plot pairs: Scatterplot Matrices panel.smooth: Simple Panel Plot par: Set or Query Graphical Parameters persp: Perspective Plots pie: Pie Charts plot.dataframe: Plot Method for Data Frames plot.default: The Default Scatterplot Function plot.design: Plot Univariate Effects of a Design or Model plot.factor: Plotting Factor Variables plot.formula: Formula Notation for Scatterplots plothistogram: Plot Histograms plot.raster: Plotting Raster Images plot.table: Plot Methods for 'table' Objects plot.window: Set up World Coordinates for Graphics Window plot.xy: Basic Internal Plot Function points: Add Points to a Plot polygon: Polygon Drawing polypath: Path Drawing rasterImage: Draw One or More Raster Images rect: Draw One or More Rectangles rug: Add a Rug to a Plot screen: Creating and Controlling Multiple Screens on a Single Device segments: Add Line Segments to a Plot smoothScatter: Scatterplots with Smoothed Densities Color Representation spineplot: Spine Plots and Spinograms stars: Star (Spider/Radar) Plots and Segment Diagrams stem: Stem-and-Leaf Plots stripchart: 1-D Scatter Plots strwidth: Plotting Dimensions of Character Strings and Math Expressions sunflowerplot: Produce a Sunflower Scatter Plot symbols: Draw Symbols (Circles, Squares, Stars, Thermometers,... text: Add Text to a Plot title: Plot Annotation units: Graphical Units xspline: Draw an X-spline zAxis: Generic Function to Add an Axis to a Plot What can we improve? The page or its content looks wrong I can't find what I'm looking for I have a suggestion Other Extra info (optional) Submit Improve this page

R Package Documentation

rdrr.io home R language documentation Run R code online

Browse R Packages

CRAN packages Bioconductor packages R-Forge packages GitHub packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that. Tweet to @rdrrHQ GitHub issue tracker [email protected] Personal blog Embedding an R snippet on your website

Add the following code to your website.

REMOVE THIS Copy to clipboard

For more information on customizing the embed code, read Embedding Snippets.

Close

Từ khóa » How To Use Segments Function In R