forked from ashleyrabanales/p2_rabanales
-
Notifications
You must be signed in to change notification settings - Fork 0
/
waffle_example.R
46 lines (39 loc) · 1.14 KB
/
waffle_example.R
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
34
35
36
37
38
39
40
41
42
43
44
45
46
library(tidyverse)
library(waffle)
library(ggfittext)
httpgd::hgd()
httpgd::hgd_browse()
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))
#example with heatmap
storms %>%
filter(year >= 2010) %>%
count(year, status) -> storms_df_all
storms_df_all %>%
ggplot(aes( x = years, y = status, fill = n)) +
geom_tile () +
geom_fit_text(size = 4, ))
scale_fill_viridis_c() +
coord_fixed()
#better labels
#color change
#theme
##