trend_plot | R Documentation |
Simple function to show trend in percent (y_var) between different years
(x_var) using ggplot2::geom_smooth()
.
trend_plot( df, x_var, y_var, y_breaks = 5, y_lim = c(54.9, 65.1), x_breaks = 5, y_lab = "Procent kvinnor", x_lab = "år", title = NULL, subtitle = NULL, line_color = slr_colors(1), fill_color = "#CADBD5", line_size = 1, point_size = 1, percent_accuracy = 1 )
df |
Data frame. |
x_var, y_var |
X and Y variable. |
y_breaks |
Length between each break on y-axis. |
y_lim |
Limit on y-axis. |
x_breaks |
Length between each break on x-axis. |
x_lab, y_lab |
X and Y-axis labels, use |
title |
Plot title, |
subtitle |
Small text under title, |
line_color |
Color of the line. |
fill_color |
Fill color |
line_size |
Size of the line. |
point_size |
Size of the points. |
percent_accuracy |
Set accuracy for |
ggplot object containing trend plot.
# Creating data set.seed(123) df <- data.frame(year = 2000:2017, prob = rnorm(18, 0.5, 0.02)) # Trend trend_plot(df, 'year', 'prob', y_breaks = 2, y_lim = range(df$prob) * 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.