PlotGraph2D | R Documentation |
plots a neighborhood graph in two dimensions given the 2D coordinates of the points
PlotGraph2D(AdjacencyMatrix, Points, Cls, Colors, xlab = "X", ylab = "Y", xlim,
ylim, Plotter = "native", LineColor = "grey", pch = 20, lwd = 0.1, main = "",
mainSize)
AdjacencyMatrix |
[1:n,1:n] numerical matrix consting of binary values. 1 indicates that two points have an edge, zero that they do not |
Points |
[1:n,1:2] numeric matrix of two feature |
Cls |
[1:n] numeric vector of k classes, if not set per default every point is in first class |
Colors |
Optional, string defining the k colors, one per class |
xlab |
Optional, string for xlabel |
ylab |
Optional, string for ylabel |
xlim |
Optional, [1:2] vector of x-axis limits |
ylim |
Optional, [1:2] vector of y-axis limits |
Plotter |
Optional, either |
LineColor |
Optional, color of edges |
pch |
Optional, shape of point, usally can be in a range from zero to 25, see pch of plot for details |
lwd |
width of the lines |
main |
Optional, string for the title of plot |
mainSize |
Optional, scalar for the size of the title of plot |
The points are the vertices of the graph. the adjacency matrix defines the edges. Via adjacency matrix various graphs, like from deldir package, can be used.
native plot or plotly object depending on input argument Plotter
Michael Thrun
Lecture of Knowledge Discovery II
pch
N=10
x=runif(N)
y=runif(N)
Euklid=as.matrix(dist(cbind(x,y)))
Radius=quantile(as.vector(Euklid),0.5)
RKugelGraphAdjMatrix = matrix(0, ncol = N, nrow = N)
for (i in 1:N) {
RInd = which(Euklid[i, ] <= Radius, arr.ind = TRUE)
RKugelGraphAdjMatrix[i, RInd] = 1
}
PlotGraph2D(RKugelGraphAdjMatrix,cbind(x,y))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.