autoplot-epi | R Documentation |
Automatically plot an epi_df or epi_archive
## 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",
.facet_filter = NULL,
.max_facets = deprecated()
)
## S3 method for class 'epi_archive'
autoplot(
object,
...,
.base_color = "black",
.versions = NULL,
.mark_versions = FALSE,
.facet_filter = NULL
)
## S3 method for class 'epi_df'
plot(x, ...)
## S3 method for class 'epi_archive'
plot(x, ...)
object , x |
An |
... |
< |
.color_by |
Which variables should determine the color(s) used to plot lines. Options include:
|
.facet_by |
Similar to |
.base_color |
Lines will be shown with this color if |
.facet_filter |
Select which facets will be displayed. Especially
useful for when there are many |
.max_facets |
|
.versions |
Select which versions will be displayed. By default,
a separate line will be shown with the data as it would have appeared on
every day in the archive. This can sometimes become overwhelming. For
example, daily data would display a line for what the data would have looked
like on every single day. To override this, you can select specific dates,
by passing a vector of values here. Alternatively, a sequence can be
automatically created by passing a string like For |
.mark_versions |
Logical. Indicate whether to mark each version with a vertical line. Note that displaying many versions can become busy. |
A ggplot2::ggplot object
# -- Use it on an `epi_df`
autoplot(cases_deaths_subset, cases, death_rate_7d_av)
autoplot(cases_deaths_subset, case_rate_7d_av, .facet_by = "geo_value")
autoplot(cases_deaths_subset, case_rate_7d_av,
.color_by = "none",
.facet_by = "geo_value"
)
autoplot(cases_deaths_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(cases_deaths_subset, case_rate_7d_av,
.base_color = "red", .facet_by = "geo_value"
)
# filter to only some facets, must be explicitly combined
autoplot(cases_deaths_subset, cases, death_rate_7d_av,
.facet_by = "all",
.facet_filter = (.response_name == "cases" & geo_value %in% c("tx", "pa")) |
(.response_name == "death_rate_7d_av" &
geo_value %in% c("ca", "fl", "ga", "ny"))
)
# Just an alias for convenience
plot(cases_deaths_subset, cases, death_rate_7d_av,
.facet_by = "all",
.facet_filter = (.response_name == "cases" & geo_value %in% c("tx", "pa")) |
(.response_name == "death_rate_7d_av" &
geo_value %in% c("ca", "fl", "ga", "ny"))
)
# -- Use it on an archive
autoplot(archive_cases_dv_subset, percent_cli, .versions = "week")
autoplot(archive_cases_dv_subset_all_states, percent_cli,
.versions = "week",
.facet_filter = geo_value %in% c("or", "az", "vt", "ms")
)
autoplot(archive_cases_dv_subset, percent_cli,
.versions = "month",
.facet_filter = geo_value == "ca"
)
autoplot(archive_cases_dv_subset_all_states, percent_cli,
.versions = "1 month",
.facet_filter = geo_value %in% c("or", "az", "vt", "ms"),
.mark_versions = TRUE
)
# Just an alias for convenience
plot(archive_cases_dv_subset_all_states, percent_cli,
.versions = "1 month",
.facet_filter = geo_value %in% c("or", "az", "vt", "ms"),
.mark_versions = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.