#' Function to help draw a cirle in ggplot2.
#'
#' I found it on the internet, I need to give credit at some point. But this
#' helps to create circles at a specified radius from a cartesian point.
#'
#' This function is not exported.
#'
#' @param radius is the radius
#' @param x_center is the x0 coordiante
#' @param y_center is the y0 coordiante
#' @param color is the color of the line
#' @param fill is whether to fill with a color
#'
#' @return A ggplot2 line object that is a circle.
annotate_circle_ggplot <- function(radius, x_center, y_center, color = "black",
fill = NA, ...) {
# Set x and y values and and create annotation.
x <- x_center + radius * cos(seq(0, pi, length.out=100))
ymin <- y_center + radius * sin(seq(0, -pi, length.out=100))
ymax <- y_center + radius * sin(seq(0, pi, length.out=100))
ggplot2::annotate("ribbon", x = x, ymin = ymin, ymax = ymax, color = color,
fill = fill, ...)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.