plot_line: Plot lines of numerical variables. Usefull especially for...

Description Usage Arguments Examples

View source: R/plot_lines.R

Description

This function creates nicely formatted, standardised line plots. Color and group parameters for geom_line and geom_point are automatically inherited from the fill parameter.

Usage

1
2
3
4
5
plot_line(df, x, y, fill = NULL, facet = NULL, ticks = 10,
  angle = 0, title = TRUE, subtitle = NULL, caption = NULL,
  lab_x = "Value range", lab_y = "Value range", legend = TRUE,
  hline = c(NaN), alpha = 0.7, limit_min = NA, limit_max = NA,
  theme_type = "ipsum", palette = "awtools")

Arguments

df

A data frame.

x

A categorical variable for the x axis groupings.

y

A numerical variable for the y axis levels.

fill

Select an additional grouping variable to be used for plotting. Defaults to NULL.

facet

Select an additional faceting variable to create facets. Defaults to NULL.

ticks

Select the number of ticks on the x and y axis with the number_ticks function. Defaults to 10.

angle

Select the rotation angle for the x axis labels. Defaults to 0.

title

Should the plot title appear automatically. Defaults to TRUE.

subtitle

Text that is displayed on the subtitle. Defaults to NULL.

caption

Text that is displayed on the caption. Defaults to NULL.

lab_x

Text that is displayed on the x axis. Defaults to "Value range".

lab_y

Text that is displayed on the y axis. Defaults to "Value range".

legend

Should the plot legend appear automatically. Defaults to TRUE.

hline

Should any horizontal lines be added to the plot. Defaults to c(NaN).

alpha

Select plot fill transparency. Defaults to 0.7.

limit_min

Select lower limit for the y scale. Defaults to NA.

limit_max

Select upper limit for the y scale. Defaults to NA.

theme_type

Select a theme type from themes available in the apply_theme function. Defaults to "ipsum".

palette

Select a palette type with the select_palette function. Defaults to "awtools".

Examples

 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
library(tidyverse)

tibble(
  time = 1:20,
  value = rnorm(20, 0.5, 2)
  ) %>%
  plot_line(
    x = time,
    y = value,
    ticks = 10,
    hline = 0.05
  )

tibble(
  time = 1:20,
  value = rnorm(20, 0.5, 2)
  ) %>%
  plot_line(
    x = time,
    y = value,
    ticks = 10,
    hline = 0.05,
    limit_min = -2,
    limit_max = 2
  )

konradsemsch/ggrapid documentation built on Nov. 4, 2019, 3:56 p.m.