Chisato

1 minute read

Hello! World!

Just figuring out how the blog post works with this random set of coffee data!

Espresso Drinks Visualized with ggplot2 Pie Chart

Pie chart can be created with using polar coordinate.

## Pie Chart
coffee_long  %>% ggplot() +
  geom_bar(aes(x=sqrt(total.amount)/2, y = amount, 
               fill=fct_rev(ingredient.f), width=sqrt(total.amount)), 
           stat="identity", position="fill") + 
  facet_wrap(~name2, ncol=4) +
  geom_text(aes(x=sqrt(total.amount), y=Inf, label=""), size=7) +
  theme_void(base_family="Roboto Condensed") +
  coord_polar(theta="y") +
  scale_fill_hue(name="Ingredient", l=80) +
  theme(legend.position="top")

Espresso Drinks Visualized with ggplot2 Bar Chart

## Bar Chart

coffee_long  %>% ggplot() +
  geom_bar(aes(x=3, y = amount, fill=fct_rev(ingredient.f), width=sqrt(total.amount)/2),
           stat="identity", position="stack") + 
  facet_wrap(~name2, ncol=4) +
  theme_void(base_family="Roboto Condensed") +
  scale_fill_hue(name="Ingredient", l=80) +
  theme(legend.position="top")