Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrbrmstr/ggchicklet
π« Create Chicklet (Rounded Segmented Column) Charts
https://github.com/hrbrmstr/ggchicklet
chicklet ggplot2 r rstats
Last synced: 7 days ago
JSON representation
π« Create Chicklet (Rounded Segmented Column) Charts
- Host: GitHub
- URL: https://github.com/hrbrmstr/ggchicklet
- Owner: hrbrmstr
- License: other
- Created: 2019-06-29T00:52:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-06T19:38:58.000Z (over 2 years ago)
- Last Synced: 2024-10-12T21:24:15.725Z (22 days ago)
- Topics: chicklet, ggplot2, r, rstats
- Language: HTML
- Homepage: https://cinc.rud.is/web/packages/ggchicklet/
- Size: 1.38 MB
- Stars: 170
- Watchers: 6
- Forks: 11
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- awesome-r-dataviz - ggchicklet - Create Chicklet (Rounded Segmented Column) Charts. (ggplot / Additional Plot Types)
README
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
``````{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```# ggchicklet
Create Chicklet (Rounded Segmented Column) Charts
## Description
Sometimes it is useful to stylize column charts a bit more
than just bland rectangles. Methods are provided to create rounded rectangle segmented column charts (i.e. "chicklets").## What's Inside The Tin
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```The following functions are implemented:
## Installation
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```## Usage
```{r lib-ex}
library(ggchicklet)# current version
packageVersion("ggchicklet")```
### From the NYTimes
```{r nyt, fig.width=10, fig.height=9, out.width="100%"}
library(hrbrthemes)
library(tidyverse)data("debates2019")
debates2019 %>%
filter(debate_group == 1) %>%
mutate(speaker = fct_reorder(speaker, elapsed, sum, .desc=FALSE)) %>%
mutate(topic = fct_other(
topic,
c("Immigration", "Economy", "Climate Change", "Gun Control", "Healthcare", "Foreign Policy"))
) %>%
ggplot(aes(speaker, elapsed, group = timestamp, fill = topic)) +
geom_chicklet(width = 0.75) +
scale_y_continuous(
expand = c(0, 0.0625),
position = "right",
breaks = seq(0, 14, 2),
labels = c(0, sprintf("%d min.", seq(2, 14, 2)))
) +
scale_fill_manual(
name = NULL,
values = c(
"Immigration" = "#ae4544",
"Economy" = "#d8cb98",
"Climate Change" = "#a4ad6f",
"Gun Control" = "#cc7c3a",
"Healthcare" = "#436f82",
"Foreign Policy" = "#7c5981",
"Other" = "#cccccc"
),
breaks = setdiff(unique(debates2019$topic), "Other")
) +
guides(
fill = guide_legend(nrow = 1)
) +
coord_flip() +
labs(
x = NULL, y = NULL, fill = NULL,
title = "How Long Each Candidate Spoke",
subtitle = "Nights 1 & 2 of the June 2019 Democratic Debates",
caption = "Each bar segment represents the length of a candidateβs response to a question.\n\nOriginals \n\nby @nytimes Weiyi Cai, Jason Kao, Jasmine C. Lee, Alicia Parlapiano and Jugal K. Patel\n\n#rstats reproduction by @hrbrmstr"
) +
theme_ipsum_rc(grid="X") +
theme(axis.text.x = element_text(color = "gray60", size = 10)) +
theme(legend.position = "top")
```## ggchicklet Metrics
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
By participating in this project you agree to abide by its terms.