Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot.MST

Plot method for 'MST' objects


Description

Plots a 2D Minimum Spanning Tree (MST) by producing a scatter plot with segments using the generic function plot.

Usage

## S3 method for class 'MST'
plot(x, ..., V1 = 1, V2 = 2, col.pts = "black", col.segts = "black", lty = 3)

Arguments

x

a MST class object returned by the ComputeMST function.

...

further graphical parameters.

V1

the numeric position or the name of the column to be used as the x coordinates of the points in the plot.

V2

the numeric position or the name of the column to be used as the y coordinates of the points in the plot.

col.pts

color of the points (vertices/nodes) in the plot.

col.segts

color of the segments (edges) in the plot.

lty

line type. An integer or name: 0 = "blank", 1 = "solid", 2 = "dashed", 3 = "dotted", 4 = "dotdash", 5 = "longdash", 6 = "twodash". The default for 'MST' objects is "dotted".

Examples

## 2D artifical data
set.seed(1984)
n <- 15
c1 <- data.frame(x = rnorm(n, -0.2, sd = 0.2), y = rnorm(n, -2, sd = 0.2))
c2 <- data.frame(x = rnorm(n, -1.1, sd = 0.15), y = rnorm(n, -2, sd = 0.3)) 
c3 <- c(0.55, -2.4)
d <- rbind(c1, c2, c3)
d <- as.data.frame(d)

## MST:
out <- ComputeMST(d)
out

## 2D plot:
plot(out)

# using different parameters
plot(out, col.pts = "blue", col.segts = "red", lty = 2)

emstreeR

Tools for Fast Computing and Plotting Euclidean Minimum Spanning Trees

v2.2.2
BSD_3_clause + file LICENSE
Authors
Allan Quadros [aut, cre]
Initial release
2020-11-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.