Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ggraph/R/geom_node_point.R
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
46 lines (46 sloc)
1.25 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Show nodes as points | |
#' | |
#' This geom is equivalent in functionality to [ggplot2::geom_point()] | |
#' and allows for simple plotting of nodes in different shapes, colours and sizes. | |
#' | |
#' @section Aesthetics: | |
#' `geom_node_point` understand the following aesthetics. Bold aesthetics are | |
#' automatically set, but can be overridden. | |
#' | |
#' - **x** | |
#' - **y** | |
#' - alpha | |
#' - colour | |
#' - fill | |
#' - shape | |
#' - size | |
#' - stroke | |
#' - filter | |
#' | |
#' @inheritParams ggplot2::geom_point | |
#' | |
#' @param mapping Set of aesthetic mappings created by [ggplot2::aes()] | |
#' or [ggplot2::aes_()]. By default x and y are mapped to x and y in | |
#' the node data. | |
#' | |
#' @author Thomas Lin Pedersen | |
#' | |
#' @family geom_node_* | |
#' | |
#' @examples | |
#' require(tidygraph) | |
#' gr <- create_notable('bull') %>% | |
#' mutate(class = sample(letters[1:3], n(), replace = TRUE)) | |
#' | |
#' ggraph(gr, 'stress') + geom_node_point() | |
#' @export | |
#' | |
geom_node_point <- function(mapping = NULL, data = NULL, position = 'identity', | |
show.legend = NA, ...) { | |
mapping <- aes_intersect(mapping, aes(x = x, y = y)) | |
layer( | |
data = data, mapping = mapping, stat = StatFilter, geom = GeomPoint, | |
position = position, show.legend = show.legend, inherit.aes = FALSE, | |
params = list(na.rm = FALSE, ...) | |
) | |
} |