View source: R/plot_dec_grph.R
plot_dec_grph | R Documentation |
Plot with nodes only, edges only, or both (geometric graph) over a decoration image.
plot_dec_grph(
nodes = NULL,
edges = NULL,
imgs,
site,
decor,
dir = getwd(),
nd.var = "id",
nd.color = "orange",
nd.size = 0.5,
lbl.color = "black",
lbl.size = 0.5,
ed.color = c("orange", "blue"),
ed.lwd = 1,
dir.out = dir,
out.file.name = NULL,
img.format = NULL,
res = 300
)
nodes |
dataframe of nodes. |
edges |
dataframe of edges. |
imgs |
dataframe of decorations. |
site |
name of the site. |
decor |
name of the decoration. |
dir |
data folder including the decoration images. By default the working directory. |
nd.var |
field name in the nodes data frame to be displayed as node labels. By default the identifier |
nd.color, nd.size, lbl.color, lbl.size, ed.color, ed.lwd |
graphical parameters for color and size/widths of nodes, edges, and labels. |
dir.out |
folder for the output image. By default, it coincides with the input |
out.file.name |
name of the output image, including path from current directory and extension. By default the name is automatically generated including |
img.format, res |
format and resolution of the saved images. The handled formats are |
plot nodes only (if edges = NULL
), edges only (if nodes = NULL
), or both (graph) over a decoration image.
Generates graph decoration images with nodes, edges, or both, overlapping the decoration image. If img.format=NULL
, the plot is sent to the active device and no value is returned. If img.format=
"png"
or "bmp"
or "tiff"
/"tif"
or "jpeg"
/"jpg"
or "pdf"
, the return value is a character vector with the dir/name of the saved image in the indicated format.
## Set data folder
dataDir <- system.file("extdata", package = "iconr")
## Decoration to be plotted
site <- "Brozas"
decor <- "Brozas"
## Read nodes, edges, and decorations
nds.df <- read_nds(site, decor, dataDir)
eds.df <- read_eds(site, decor, dataDir)
imgs <- read.table(paste0(dataDir, "/imgs.tsv"),
sep="\t", stringsAsFactors = FALSE)
## Plot 'Brozas' nodes and edges on the active device
## with node variable "type" as labels
plot_dec_grph(nds.df, eds.df, imgs,
site, decor,
dir = dataDir,
lbl.size = 0.4,
nd.var = "type")
## Save only edges of 'Brozas' with bigger widths and in image format jpg.
outDir <- tempdir()
img.filename <- plot_dec_grph(nodes = NULL, eds.df, imgs,
site, decor,
dir = dataDir,
ed.lwd = 2,
dir.out = outDir,
img.format = "jpg")
## Then read and plot the image.
a.dec <- magick::image_read(img.filename)
## Inspect the output image
magick::image_info(a.dec)
## Plot the output image
plot(a.dec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.