theme_line_dft | R Documentation |
Applies a standardised DfT theme to a ggplot line plot.
theme_line_dft(
legend_position = "none",
base_family = "",
base_size = 14,
base_line_size = 2,
margin_sizes = c(2, 1, 1, 1),
accuracy = 1,
labels = TRUE,
palette = "main.palette",
gradient = FALSE,
label_size = 0.8,
label_nudge = 1,
...
)
legend_position |
the desired legend position. Selects bottom by default. |
base_family |
Font family |
base_size |
The base font size |
base_line_size |
The base line size |
margin_sizes |
The margin size in cm. Takes a list of the four margins in the order top, right, bottom, left. |
accuracy |
The accuracy of the y-axis, default to 1 for 0 decimal place. 0.1 would give 1 decimal place, 0.01 would give 2 decimal places. |
labels |
Booleans reponse whether to directly label lines on the chart. Defaults to TRUE |
palette |
The name of the DfT palette you want to use |
gradient |
Boolean response whether to use gradient palette instead of standard palettes. Defaults to false. |
label_size |
numeric quantity to set size of font |
label_nudge |
numeric quantity to move labels to the right (greater than 1) or left (less than 1) |
... |
Other arguments to pass to extract gradients function |
This theme has been designed using charting best practice principles.
## Simple line plot using standard line theme with default options
library(ggplot2)
df <- economics_long[economics_long$variable %in% c("psavert", "uempmed"), ]
# plot
ggplot(df, aes(x=date, y=value, col=variable, label=variable)) +
geom_line(size = 1) +
theme_line_dft()
## More complex line plot selecting another dft palette
library(ggplot2)
df <- economics_long[economics_long$variable %in% c("psavert", "uempmed"), ]
# plot
ggplot(df, aes(x=date, y=value, col=variable, label=variable)) +
geom_line(size = 1) +
theme_line_dft(palette = "clear.skies")
## More complex line plot using a gradient palette with two groups
library(ggplot2)
df <- economics_long[economics_long$variable %in% c("psavert", "uempmed"), ]
# plot
ggplot(df, aes(x=date, y=value, col=variable, label=variable)) +
geom_line(size = 1) +
theme_line_dft(gradient = TRUE, n=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.