Easily create a lollipop chart
lollipop_chart( data, x, y, facet = NULL, ..., line_size = 0.75, line_color = "auto", point_size = 4, point_color = line_color, highlight = NULL, sort = TRUE, horizontal = TRUE, top_n = NULL, threshold = NULL, other = FALSE, limit = NULL )
data | Dataset to use for the bar chart |
---|---|
x |
|
y |
|
facet |
|
... | Additional arguments passed to |
line_size |
|
line_color |
|
point_size |
|
point_color |
|
highlight |
|
sort |
|
horizontal |
|
top_n |
|
threshold |
|
other |
|
limit | Deprecated. use |
An object of class ggplot
Both top_n
and threshold
only work when sort = TRUE
.
Attempting to use them when sort = FALSE
will result in an error.
Furthermore, only top_n
or threshold
can be used at a time.
Providing a value for both top_n
and threshold
will result in
an error as well.
For more details have a look at these vignettes:
vignette("highlight", package = "ggcharts")
vignette("customize", package = "ggcharts")
data(biomedicalrevenue) revenue2016 <- biomedicalrevenue[biomedicalrevenue$year == 2016, ] revenue_bayer <- biomedicalrevenue[biomedicalrevenue$company == "Bayer", ] ## By default lollipop_chart() creates a horizontal and sorted plot lollipop_chart(revenue2016, company, revenue)## If the `y` argument is missing the count of each value in `x` is displayed lollipop_chart(mtcars, cyl)## Create a vertical, non-sorted lollipop chart lollipop_chart(revenue_bayer, year, revenue, horizontal = FALSE, sort = FALSE)## Limit the number of lollipops to the top 15 lollipop_chart(revenue2016, company, revenue, top_n = 15)## Display only companies with revenue > 50B. lollipop_chart(revenue2016, company, revenue, threshold = 50)## Change the color of the whole lollipop lollipop_chart(revenue2016, company, revenue, line_color = "purple")## Change the color of the lollipop stick and head individually lollipop_chart(revenue2016, company, revenue, point_color = "darkgreen", line_color = "gray")## Decrease the lollipop head size lollipop_chart(revenue2016, company, revenue, point_size = 2.5)## Highlight a single lollipop lollipop_chart(revenue2016, company, revenue, top_n = 15, highlight = "Roche")## Use facets to show the top 10 companies over the years lollipop_chart(biomedicalrevenue, company, revenue, facet = year, top_n = 10)