Description Usage Arguments Details Value Examples
View source: R/plot_dec_grph.R
Plot with nodes only, edges only, or both (geometric graph) over a decoration image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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 If set, |
img.format, res |
Format and resolution of the saved images. The handled formats are
if |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ## 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.