plot.covidcast_signal | R Documentation |
covidcast_signal
object as choropleths, bubbles, or time seriesSeveral plot types are provided, including choropleth plots (maps), bubble
plots, and time series plots showing the change of signals over time, for a
data frame returned by covidcast_signal()
. (Only the latest issue from the
data frame is used for plotting.) See vignette("plotting-signals", package = "covidcast")
for examples.
## S3 method for class 'covidcast_signal'
plot(
x,
plot_type = c("choro", "bubble", "line"),
time_value = NULL,
include = c(),
range = NULL,
choro_col = c("#FFFFCC", "#FD893C", "#800026"),
alpha = 0.5,
bubble_col = "purple",
num_bins = 8,
title = NULL,
choro_params = list(),
bubble_params = list(),
line_params = list(),
...
)
x |
The |
plot_type |
One of "choro", "bubble", "line" indicating whether to plot a choropleth map, bubble map, or line (time series) graph, respectively. The default is "choro". |
time_value |
Date object (or string in the form "YYYY-MM-DD") specifying
the day to map, for choropleth and bubble maps. If |
include |
Vector of state abbreviations (case insensitive, so "pa" and
"PA" both denote Pennsylvania) indicating which states to include in the
choropleth and bubble maps. Default is |
range |
Vector of two values: min and max, in this order, to use when
defining the color scale for choropleth maps and the size scale for bubble
maps, or the range of the y-axis for the time series plot. If |
choro_col |
Vector of colors, as specified in hex code, to use for the choropleth color scale. Can be arbitrary in length. Default is similar to that from https://delphi.cmu.edu/covidcast/. |
alpha |
Number between 0 and 1, indicating the transparency level to be used in the maps. For choropleth maps, this determines the transparency level for the mega counties. For bubble maps, this determines the transparency level for the bubbles. Default is 0.5. |
bubble_col |
Bubble color for the bubble map. Default is "purple". |
num_bins |
Number of bins for determining the bubble sizes for the
bubble map (here and throughout, to be precise, by bubble size we mean
bubble area). Default is 8. These bins are evenly-spaced in between the min
and max as specified through the |
title |
Title for the plot. If |
choro_params, bubble_params, line_params |
Additional parameter lists for the different plot types, for further customization. See details below. |
... |
Additional arguments, for compatibility with |
The following named arguments are supported through the lists
choro_params
, bubble_params
, and line_params
.
For both choropleth and bubble maps:
subtitle
Subtitle for the map.
missing_col
Color assigned to missing or NA geo locations.
border_col
Border color for geo locations.
border_size
Border size for geo locations.
legend_position
Position for legend; use "none" to hide legend.
legend_height
, legend_width
Height and width of the legend.
breaks
Breaks for a custom (discrete) color or size scale. Note
that we must set breaks
to be a vector of the same length as choro_col
for choropleth maps. This works as follows: we assign the i
th color for
choropleth maps, or the i
th size for bubble maps, if and only if the
given value satisfies breaks[i] <= value < breaks[i+1]
, where we take by
convention breaks[0] = -Inf
and breaks[N+1] = Inf
for N = length(breaks)
.
legend_digits
Number of decimal places to show for the legend labels.
For choropleth maps only:
legend_n
Number of values to label on the legend color bar. Ignored
for discrete color scales (when breaks
is set manually).
For bubble maps only:
remove_zero
Should zeros be excluded from the size scale (hence effectively drawn as bubbles of zero size)?
min_size
, max_size
Min size for the size scale.
For line graphs:
xlab
, ylab
Labels for the x-axis and y-axis.
stderr_bands
Should standard error bands be drawn?
stderr_alpha
Transparency level for the standard error bands.
A ggplot
object that can be customized and styled using standard
ggplot2 functions.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.