djpr_axes: Don't expand below the y axis / to the left of the x-axis.

djpr_axesR Documentation

Don't expand below the y axis / to the left of the x-axis.

Description

These functions are particularly useful for bar charts and similar charts with a zero baseline.

Usage

djpr_y_continuous(expand_bottom = 0, expand_top = 0.015, ...)

djpr_x_continuous(expand_left = 0, expand_right = 0.015, ...)

Arguments

expand_bottom

default is 0. This will ensure that your x-axis is at the bottom value of your plotted data. Increase to add some buffer between the lowest point in your data and the x-axis. Note that the value is interpreted as a fraction of the total plotting space - a value of 1 will add white space equal to the whole area of your data.

expand_top

default is 0.015. This will ensure that a small amount of white space is added to the top of your chart. Increase to add more white space.

...

arguments passed to scale_y_continuous or scale_x_continuous

expand_left

default is 0. This will ensure your y-axis is at the lowest value of your plotted value.

expand_right

default is 0.015. This will ensure that a small amount of white space is added to the right of your chart.

Author(s)

Matt Cowgill

Examples


# Here's a basic chart in the DJPR style:
library(ggplot2)

p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_djpr()

# By default our chart (p) will have a little whitespace below the
# 10 on the y axis. Remove that with:

p +
  djpr_y_continuous()

# These functions are particularly useful with bar charts
library(dplyr)
p2 <- iris %>%
  group_by(Species) %>%
  summarise(length = mean(Sepal.Length)) %>%
  ggplot(aes(x = Species, y = length)) +
  geom_col() +
  theme_djpr()

# p2 has space below the 0 line, which we don't want
p2 +
  djpr_y_continuous()

djpr-data/djprtheme documentation built on April 15, 2023, 2:47 a.m.