Skip to content

Commit

Permalink
Made sure that the y-axis starts at 0 in plots.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmueller18 committed Mar 11, 2024
1 parent 0c4c024 commit 80315ce
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/plot_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ make_ggplot <- function(data, variable_name, variable_labels, line_vis) {
} else if (line_vis %in% c("colour", "color")) {
my_plot <- ggplot2::ggplot(my_x, ggplot2::aes(x=!! rlang::sym("a"),y=!! rlang::sym(variable_name), color = dataset))
}
my_plot <- my_plot + ggplot2::geom_line() + ggplot2::xlab("age") + ggplot2::ylab(variable_name) + ggplot2::ggtitle(variable_labels[variable_name])
my_plot <- my_plot + ggplot2::geom_line() + ggplot2::xlab("age") + ggplot2::ylab(variable_name) +
ggplot2::ggtitle(variable_labels[variable_name]) + ggplot2::expand_limits(y = 0)
# check if group attribute is present to pass it on for plot legend title
group <- attributes(data)$group
if(is.null(group) %>% `!` && group %>% is.na %>% `!`) {my_plot <- my_plot + ggplot2::guides(linetype=ggplot2::guide_legend(title=group))}
Expand Down

0 comments on commit 80315ce

Please sign in to comment.