djpr_axes | R Documentation |
These functions are particularly useful for bar charts and similar charts with a zero baseline.
djpr_y_continuous(expand_bottom = 0, expand_top = 0.015, ...)
djpr_x_continuous(expand_left = 0, expand_right = 0.015, ...)
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. |
Matt Cowgill
# 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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.