stamp_heart: Stamp a heart of n sides

View source: R/stamp_heart.R

stamp_heartR Documentation

Stamp a heart of n sides

Description

This function adds a text annotation layer. Contribute or help document https://github.com/EvaMaeRey/ggstamp/blob/master/R/stamp_polygon.R

Usage

stamp_heart(
  x0 = 0,
  y0 = 0,
  n_vertices = 200,
  radius = 1,
  size = 1.5,
  alpha = 1,
  rotation = 0,
  linetype = "solid",
  fill = "grey35",
  color = "black",
  x0y0 = NULL
)

Arguments

x0

numeric x center of shape, defaults to 0

y0

numeric y center of shape, defaults to 0

size

numeric value indicating line width, defaults to 1.5

alpha

numeric between 0 and 1 indicating transparency, defaults to 1 fully opaque, zero is fully transparent

rotation

how much the shape should be rotated, defaults to -.5

linetype

a string indicating linetype, "solid", "dashed", "dotted", defaults to "solid"

fill

a character string indicating fill color, defaults to "grey35", for other named colors check out https://evamaerey.github.io/ggplot2_grammar_guide/named_colors

color

a character string indicating color, defaults to "black", for other named colors check out https://evamaerey.github.io/ggplot2_grammar_guide/named_colors

x0y0

dataframe indicating center of shapes, where first column is vector for x values and second column is vector for y values, defaults to NULL

Examples

# on plot space
library(ggplot2)
ggplot(cars) +
 aes(speed, dist) +
 geom_point() +
 stamp_heart(color = "darkred",
             fill = "pink")

 ggcanvas() +
  stamp_heart()

# on a canvas
 ggcanvas() +
  stamp_heart(n = 18, x0 = c(0, 2.5),
  fill = "magenta", color = "purple") +
  stamp_label(x = pos_polygon_x(x0 = 0, n = 3),
              y = pos_polygon_y(y0 = 0, n = 3),
              label = c("hi", "hello", "bye")) +
  stamp_point(color = "turquoise")

# lots of polygons
 ggcanvas() +
 stamp_heart(color = "turquoise4", radius = 3, fill = "turquoise") +
 stamp_heart(fill = "slateblue2") +
 stamp_heart(linetype = "dashed", alpha = .5, fill = "plum2") +
 stamp_heart(x0 = 1, y0 = 1.5, n = 3, rotation = .25, size = 0,
  fill = "goldenrod2") +
 stamp_heart(n = 50, radius = .2, size = 0) +
 stamp_spoke(angle = pi * 1:7/15, radius = 2)

# some more
 ggcanvas() +
  stamp_heart(x0y0 = pos_wrap(n = 5, ncol = 3, height = 1.5),
                radius = .5) +
  stamp_text(xy = pos_wrap(n = 5, ncol = 3,
           height = 1.5), label = LETTERS[1:5])


EvaMaeRey/ggstamp documentation built on June 30, 2022, 11 p.m.