Description Usage Arguments Details Value Examples
Pass in a data frame and get back a square choropleth.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | statebins(
state_data,
state_col = "state",
value_col = "value",
dark_label = "black",
light_label = "white",
na_label = "white",
font_size = 3,
state_border_col = "white",
state_border_size = 2,
round = FALSE,
radius = grid::unit(6, "pt"),
ggplot2_scale_function = ggplot2::scale_fill_distiller,
...
)
|
state_data |
data frame of states and values to plot |
state_col |
column name in |
value_col |
column name in |
dark_label, light_label, na_label |
dark/light/NA label colors. The specified color will be used when the algorithm determines labels should be inverted. |
font_size |
font size (default = |
state_border_col |
default " |
state_border_size |
border size |
round |
rounded corners (default: |
radius |
if |
ggplot2_scale_function |
ggplot2 scale function to use. Defaults to |
... |
additional parameters to the scale function |
The state_col
and value_col
parameters default to state
and value
. That means
if you name the columns you want to plot with those names, you can forego passing them
in. Othersise, use "strings"
.
A handy feature of this function is that you can specify a dark_label
color
and a light_label
color. What does that mean? Well, you also pass in the
color scale function you're going to use and statebins
will apply it and use
that information to determine what the tile color is and — if it's "dark" it will
use the light_label
and if it's "light" it will use the dark_label
color. That
means the labels will never blend in to the background (as long as you specify
decent label colors).
You can customize the scale function you pass in by using name parameters. All named
parameters not used by statebins()
itself get passed to the scale function.
ggplot2 object
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.