Skip to contents

Automatically plot an epi_df

Usage

# S3 method for class 'epi_df'
autoplot(
  object,
  ...,
  .color_by = c("all_keys", "geo_value", "other_keys", ".response", "all", "none"),
  .facet_by = c(".response", "other_keys", "all_keys", "geo_value", "all", "none"),
  .base_color = "#3A448F",
  .max_facets = Inf
)

Arguments

object

An epi_df

...

<tidy-select> One or more unquoted expressions separated by commas. Variable names can be used as if they were positions in the data frame, so expressions like x:y can be used to select a range of variables.

.color_by

Which variables should determine the color(s) used to plot lines. Options include:

  • all_keys - the default uses the interaction of any key variables including the geo_value

  • geo_value - geo_value only

  • other_keys - any available keys that are not geo_value

  • .response - the numeric variables (same as the y-axis)

  • all - uses the interaction of all keys and numeric variables

  • none - no coloring aesthetic is applied

.facet_by

Similar to .color_by except that the default is to display each numeric variable on a separate facet

.base_color

Lines will be shown with this color. For example, with a single numeric variable and faceting by geo_value, all locations would share the same color line.

.max_facets

Cut down of the number of facets displayed. Especially useful for testing when there are many geo_value's or keys.

Value

A ggplot object

Examples

autoplot(jhu_csse_daily_subset, cases, death_rate_7d_av)

autoplot(jhu_csse_daily_subset, case_rate_7d_av, .facet_by = "geo_value")

autoplot(jhu_csse_daily_subset, case_rate_7d_av,
  .color_by = "none",
  .facet_by = "geo_value"
)

autoplot(jhu_csse_daily_subset, case_rate_7d_av,
  .color_by = "none",
  .base_color = "red", .facet_by = "geo_value"
)


# .base_color specification won't have any effect due .color_by default
autoplot(jhu_csse_daily_subset, case_rate_7d_av,
  .base_color = "red", .facet_by = "geo_value"
)