Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/lollipop_chart.R
Easily create a lollipop chart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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 |
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.
An object of class ggplot
Thomas Neitmann
For more details have a look at these vignettes:
vignette("highlight", package = "ggcharts")
vignette("customize", package = "ggcharts")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.