disk | R Documentation |
Center disks at points in a scatterplot.
geom_disk(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
na.rm = FALSE,
radius = NULL,
diameter = NULL,
segments = 60L,
show.legend = NA,
inherit.aes = TRUE,
...
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
na.rm |
Logical; ignored. |
radius , diameter |
The (positive) radius or diameter used in the construction. Provide only one of these; if neither is provided, they default to zero. |
segments |
The number of segments in the regular polygon that approximates each disk |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Additional arguments passed to |
A ball of radius r
around a point x
in Euclidean space consists
of all points whose distances from x
are less than r
. A ball in 2
dimensions is called a disk.
The geometric objects of GeomDisk
can be used to illustrate disk covers of
point clouds, in particular in the construction of simplicial filtrations. It
could be paired with a statistical transformation of Stat*
that samples
points from a cloud.
The convenience function geom_disk()
produces a layer with the identity
statistical transformation.
geom_disk()
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
colour
fill
group
linetype
linewidth
Learn more about setting these aesthetics in vignette("ggplot2-specs", package = "ggplot2")
.
ggplot2::layer()
for additional arguments.
Other plot layers for point clouds:
simplicial_complex
# function to generate noisy 2D circles
make_noisy_circle <- function(n, sd = .01) {
theta <- stats::runif(n = n, min = 0, max = 2*pi)
cbind(x = cos(theta) + stats::rnorm(n, 0, sd),
y = sin(theta) + stats::rnorm(n, 0, sd))
}
# generate a noisy 2D circle
set.seed(1)
d <- as.data.frame(make_noisy_circle(n = 36L, sd = .15))
r <- 1/6
# plot disks beneath points
ggplot(d, aes(x = x, y = y)) +
theme_bw() +
coord_fixed() +
geom_disk(radius = r, fill = "aquamarine3") +
geom_point()
# use `diameter` parameter
ggplot(d, aes(x = x, y = y)) +
theme_bw() +
coord_fixed() +
geom_disk(diameter = 2*r, fill = "aquamarine3") +
geom_point()
# generate a noisy 2D circle
set.seed(2)
theta <- stats::runif(n = 40L, min = 0, max = 2*pi)
d <- data.frame(x = cos(theta) + stats::rnorm(40L, 0, .15),
y = sin(theta) + stats::rnorm(40L, 0, .15))
r <- 1/3
# overlay ball cover and Vietoris-Rips complex with points
ggplot(d, aes(x = x, y = y)) +
theme_bw() +
coord_fixed() +
geom_disk(radius = r, fill = "aquamarine3") +
geom_simplicial_complex(
radius = r, fill = "darkgoldenrod",
complex = "Vietoris", engine = "base"
) +
geom_point()
# use the Čech complex instead
ggplot(d, aes(x = x, y = y)) +
theme_bw() +
coord_fixed() +
geom_disk(radius = r, fill = "aquamarine3") +
geom_simplicial_complex(
radius = r, fill = "darkgoldenrod",
complex = "Cech", engine = "base"
) +
geom_point()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.