geom_bullseye | R Documentation |
geom_bullseye
create a bullet chart with all the circles aligned to the bottom.
geom_bullseye(
mapping = NULL,
data = NULL,
geom = "polygon",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to |
Since this is a specialized plot, it requires data in a specific format (similar to line charts). The x
parameter
must be the proportion of each category (i.e. the percentage one category is from the total). A group
must also be
provided in a form of fill, group, color
. It is also recommended to add coord_equal
and to adjust
the theme to something more minimal (e.g. ggthemes::theme_map()
). Labeling the circles may be difficult at this time, but
a future version may make this easier without having to do additional calculations for ideal placement. Factor levels may
also need to be reordered (e.g. using forcats
). Alternatively, instead of using this custom Stat, one could just use programming methods with ggplot2.
## Not run:
library(ggplot2)
library(magrittr)
library(tibble)
library(forcats)
# Create data
data <- tribble(~Grouping, ~Cases,
"Step1", 4000,
"Step2", 2300,
"ThirdStep", 200,
"Step4", 20)
# Plot data
ggplot(data = data, aes(x = Cases, fill = fct_rev(fct_reorder(Grouping, Cases)))) +
geom_bullseye()
coord_equal() +
ggthemes::theme_map() +
theme(legend.title = element.blank(),
legend.position = 'right')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.