gplot {GSD} | R Documentation |
Plot of a Graph Signal
Description
This function displays a signal on a graph using a color palette.
Usage
gplot(graph, signal = NULL, size = 1, limits = range(V(graph)$z),
gpalette = NULL, legend = TRUE)
Arguments
graph |
an igraph graph object with vertex attributes of coordinates |
signal |
specifies a signal to be displayed over object |
size |
specifies point size of vertex. |
limits |
specifies color palette limits. |
gpalette |
specifies a character vector of color palette. When |
legend |
if |
Details
This function displays a signal on a graph using a color palette.
Value
plot of a signal over a graph using package ggplot2.
See Also
Examples
#### example : composite of two components having different frequencies
## define vertex coordinate
x <- y <- seq(0, 1, length=30)
xy <- expand.grid(x=x, y=y)
## weighted adjacency matrix by Gaussian kernel
## for connecting vertices within distance 0.04
A <- adjmatrix(xy, method = "dist", 0.04)
## signal
# high-frequency component
signal1 <- rep(sin(12.5*pi*x - 1.25*pi), 30)
# low-frequency component
signal2 <- rep(sin(5*pi*x - 0.5*pi), 30)
# composite signal
signal0 <- signal1 + signal2
# noisy signal with SNR(signal-to-noise ratio)=5
signal <- signal0 + rnorm(900, 0, sqrt(var(signal0) / 5))
# graph with signal
gsig <- gsignal(vertex = cbind(xy, signal), edge = A, edgetype = "matrix")
# display a signal over graph with legend
gplot(gsig, size=3, legend=TRUE)
# display a signal over graph without legend
gplotout <- gplot(gsig, size=3, legend=FALSE)
gplotout
# adding labels using ggplot2 package
gplotout +
theme(axis.title=element_text(),
plot.title=element_text(hjust = 0.5, vjust = 0)) +
labs(x="x", y="y", title="visualization of a composite signal")
# deleting axis title, text and ticks using ggplot2 package
gplotout +
theme(axis.title=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank())
# display high-frequency component
gplot(gsig, signal1, size=3, legend=FALSE)
# display low-frequency component
gplot(gsig, signal2, size=3, legend=FALSE)
[Package GSD version 1.0.0 Index]