Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waffle plots #1

Open
andrewcstewart opened this issue Sep 8, 2020 · 1 comment
Open

Waffle plots #1

andrewcstewart opened this issue Sep 8, 2020 · 1 comment
Labels
plot types Types of plots to try

Comments

@andrewcstewart
Copy link
Owner

image

@andrewcstewart andrewcstewart added the plot types Types of plots to try label Sep 8, 2020
@andrewcstewart
Copy link
Owner Author

image

library(dplyr)
library(waffle)

storms %>% 
  filter(year >= 2010) %>% 
  count(year, status) -> storms_df

ggplot(storms_df, aes(fill = status, values = n)) +
  geom_waffle(color = "white", size = .25, n_rows = 10, flip = TRUE) +
  facet_wrap(~year, nrow = 1, strip.position = "bottom") +
  scale_x_discrete() + 
  scale_y_continuous(labels = function(x) x * 10, # make this multiplyer the same as n_rows
                     expand = c(0,0)) +
  ggthemes::scale_fill_tableau(name=NULL) +
  coord_equal() +
  labs(
    title = "Faceted Waffle Bar Chart",
    subtitle = "{dplyr} storms data",
    x = "Year",
    y = "Count"
  ) +
  theme_minimal(base_family = "Roboto Condensed") +
  theme(panel.grid = element_blank(), axis.ticks.y = element_line()) +
  guides(fill = guide_legend(reverse = TRUE))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plot types Types of plots to try
Projects
None yet
Development

No branches or pull requests

1 participant