Nothing
#' Draw a flow chart from edge data
#'
#' `ggflow()` is a thin wrapper around [ggplot.igraph()] and [geom_edge()]
#' for `from`/`to` edge lists. It used to live in the standalone **ggflow**
#' package, which is now retired: flow charts are directed graphs, not trees,
#' so they belong here rather than in `ggtreeDendro`.
#'
#' @title ggflow
#' @param data a data frame with 'from' and 'to' columns, or an igraph object
#' @param layout network layout passed to [ggplot.igraph()]; the default is
#' `igraph::layout_as_tree`
#' @param start_shave amount removed from the start of each edge
#' @param end_shave amount removed from the end of each edge, before the arrowhead
#' @param type_shave whether shaving is a proportion of edge length or a distance
#' @param ... additional parameters passed to [geom_edge()] (e.g. `arrow`)
#' @return a ggplot object
#' @importFrom igraph graph_from_data_frame
#' @importFrom ggfun geom_scatter_rect
#' @export
#' @author Guangchuang Yu
#' @examples
#' library(ggtangle)
#' d <- data.frame(
#' from = c("A", "A", "A", "B", "C", "F"),
#' to = c("B", "C", "D", "E", "F", "G")
#' )
#' ggflow(d, arrow = arrow(type = 'closed')) +
#' ggfun::geom_scatter_rect(fill = NA, color = 'black') +
#' geom_text(aes(label = label), size = 10)
ggflow <- function(data, layout = igraph::layout_as_tree, start_shave = 0.3,
end_shave = 0.3,
type_shave = "proportion", ...) {
if (inherits(data, "igraph")) {
g <- data
} else {
g <- graph_from_data_frame(data)
}
ggplot(g, layout = layout) + geom_edge(
start_shave = start_shave, end_shave = end_shave,
type_shave = type_shave, ...
)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.