R/bbd_drop_axis.R

Defines functions bbd_drop_axis

Documented in bbd_drop_axis

#' Custom [ggplot2] theme for personal use by Bluebonnet Data
#'
#' Drops tick axes and axes labels
#'
#' @example \dontrun{
#' plot + bbd_drop_axis(axis = "both")
#' }
#'
#' @param axis Axis to drop "x", "y", "both", or "neither". The function will keep whatever is not included in "drop."
#'
#' @md
#' @export
bbd_drop_axis <- function(axis = "both") {

  if (axis == "y") {

    ggplot2::theme(axis.line.x = ggplot2::element_line(colour = NULL,
                                                       size = NULL,
                                                       linetype = NULL,
                                                       lineend = NULL),
                   axis.line.y = ggplot2::element_blank())

  } else if (axis == "x") {

    ggplot2::theme(axis.line.x = ggplot2::element_blank(),
                   axis.line.y = ggplot2::element_line(colour = NULL,
                                                       size = NULL,
                                                       linetype = NULL,
                                                       lineend = NULL),
                   axis.ticks.x = ggplot2::element_blank()
    )

  } else if (axis == "neither") {

    ggplot2::theme(axis.line.x = ggplot2::element_line(colour = NULL,
                                                       size = NULL,
                                                       linetype = NULL,
                                                       lineend = NULL),
                   axis.line.y = ggplot2::element_line(colour = NULL,
                                                       size = NULL,
                                                       linetype = NULL,
                                                       lineend = NULL)
    )

  } else if (axis == "both") {

    ggplot2::theme(axis.line.x = ggplot2::element_blank(),
                   axis.line.y = ggplot2::element_blank(),
                   axis.ticks.x = ggplot2::element_blank()
    )

  } else {

    stop('Invalid "axis" argument. Valid arguments are: ',
         '"x", "y", "both", and "neither."',
         call. = FALSE)
  }
}
connorrothschild/bbdata documentation built on June 22, 2020, 11:16 a.m.