Description Usage Arguments Examples
Ensure your y- and x-axis are Grattan style guide-consistent and doesn't hang off the edge of the chart.
1 2 3 4 | aig_y_continuous(expand_bottom = 0, expand_top = 0.07, ...)
scale_y_continuous_aig(expand_bottom = 0, expand_top = 0.07, ...)
aig_x_continuous(expand_left = 0, expand_right = 0.07, ...)
scale_x_continuous_aig(expand_left = 0, expand_right = 0.0, ...)
|
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.07. 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.07. This will ensure that a small amount of white space is added to the right of your chart. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # Here's a basic chart in the Grattan style:
library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
aig_style()
p
# In the example above, the top label on the y-axis is hanging off the top.
# To fix:
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
aig_y_continuous() +
aig_style()
p
# Now the top of the chart looks fine, but the bottom has two points
# (at the lower right) that are partially obscured.
# We could fix this by doing:
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
aig_y_continuous(expand_bottom = 0.015) +
theme_aig()
p
# Alternatively, set the limits of the chart (in this example we'll set
# the lower limit to 0, but you could use some other value
# like 10 in this case).Note that by setting the second value of limits
# to NA, we're telling ggplot2 to calculate theupper limit as usual based
# on the data. All the usual arguments of `scale_y_continuous()`
# (limits, breaks, labels, etc.) can be used.
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
aig_y_continuous(limits = c(0, NA)) +
theme_aig()
p
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.