View source: R/utils.R View source: R/utils.R
geom_dice_sf | R Documentation |
Creates a ggplot2 layer that places dice representations on spatial features in an sf object. The dice values are determined by a column in the sf object.
Creates a ggplot2 layer that places dice representations on spatial features in an sf object. The dice values are determined by a column in the sf object.
geom_dice_sf(
sf_data,
dice_value_col = "dice",
face_color = NULL,
dice_color = "white",
dice_size = 3,
dot_size = NULL,
rectangle_padding = 0.05,
...
)
geom_dice_sf(
sf_data,
dice_value_col = "dice",
face_color = NULL,
dice_color = "white",
dice_size = 3,
dot_size = NULL,
rectangle_padding = 0.05,
...
)
sf_data |
An sf object containing the spatial features. |
dice_value_col |
Character. Name of the column in sf_data containing dice values (1-6). Default is "dice". |
face_color |
Character vector. Column names in sf_data containing color information for each dice dot. If NULL (default), all dots are black. |
dice_color |
Character. Background color of the dice. Default is "white". |
dice_size |
Numeric. Size of the dice. Default is 3. |
dot_size |
Numeric. Size of the dots on the dice. If NULL (default), it's calculated as 20% of dice_size. |
rectangle_padding |
Numeric. Padding of the rectangle around the dots, as a proportion of dice_size. Default is 0.05. |
... |
Additional arguments passed to geom_point for the dots. |
A list of ggplot2 layers (rectangle layer and dots layer).
A list of ggplot2 layers (rectangle layer and dots layer).
## Not run:
library(ggplot2)
library(sf)
# Create sample sf data with dice values
nc <- st_read(system.file("shape/nc.shp", package = "sf"))
nc$dice <- sample(1:6, nrow(nc), replace = TRUE)
# Basic plot with dice
ggplot(nc) +
geom_sf() +
geom_dice_sf(sf_data = nc)
# Customized dice
ggplot(nc) +
geom_sf() +
geom_dice_sf(sf_data = nc, dice_color = "lightblue", dice_size = 5)
## End(Not run)
## Not run:
library(ggplot2)
library(sf)
# Create sample sf data with dice values
nc <- st_read(system.file("shape/nc.shp", package = "sf"))
nc$dice <- sample(1:6, nrow(nc), replace = TRUE)
# Basic plot with dice
ggplot(nc) +
geom_sf() +
geom_dice_sf(sf_data = nc)
# Customized dice
ggplot(nc) +
geom_sf() +
geom_dice_sf(sf_data = nc, dice_color = "lightblue", dice_size = 5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.