Declare the scale for a mapped edge aesthetic on a vgraph() plot – the
colour (mark_edges(color = )), opacity (alpha = ), or line type
(linetype = ) of the edges. These are the edge counterparts of
scale_color_continuous() / scale_alpha() / scale_linetype(): an edge
aesthetic is trained and legended independently of the node scales, so a
figure can map, say, node fill to a discrete community and edge colour to a
continuous weight without the two collapsing into one legend. Each draws its
own legend automatically.
Usage
scale_edge_color(
plot,
palette = NULL,
breaks = NULL,
labels = NULL,
name = NULL,
midpoint = NULL
)
scale_edge_colour(
plot,
palette = NULL,
breaks = NULL,
labels = NULL,
name = NULL,
midpoint = NULL
)
scale_edge_alpha(plot, range = NULL, limits = NULL, breaks = NULL, name = NULL)
scale_edge_linetype(plot, values = NULL, name = NULL)Arguments
- plot
- palette
For
scale_edge_color(), a vector of colours or a single palette name (as inscale_color_continuous());NULLfor a default.- name
Legend title, or
NULLto derive from the encoding.- midpoint
For
scale_edge_color(), the data value placed at the ramp's midpoint (a diverging scale);NULLfor an ordinary ramp.- range
For
scale_edge_alpha(), the output opacity rangec(min, max), orNULLfor the default.- limits, breaks, labels
Data limits, explicit legend breaks, and explicit labels, or
NULLto derive from the data.- values
For
scale_edge_linetype(), a character vector of line types (as inscale_linetype());NULLfor the default palette.
Value
The modified PlotSpec.
Details
scale_edge_color() infers discrete vs continuous from the mapped data (a
factor/character trains a discrete swatch legend; a number a colour bar), the
same as the node colour scale. scale_edge_colour() is a British-spelling
alias.
Examples
if (FALSE) { # \dontrun{
g <- igraph::make_graph("Zachary")
g <- igraph::set_edge_attr(g, "w", value = runif(igraph::ecount(g)))
vgraph(g) |>
mark_edges(color = w) |>
mark_nodes(fill = factor(igraph::membership(igraph::cluster_louvain(g)))) |>
scale_edge_color(palette = "Grays")
} # }
