gg_chart: Use ggplot2 to plot some quantity by year

gg_annual_chartR Documentation

Use ggplot2 to plot some quantity by year

Description

Use gg_annual_chart(), not gg_chart() (the latter is deprecated). You must add geom_area(...) or geom_line(...) to the result. See example below.

Usage

gg_annual_chart(chart_data, qty_var = NULL, format = NULL, ..., verbose = TRUE)

gg_chart(chart_data, ..., verbose = TRUE)

Examples

test_yrs <- RY(2014:2016)
chart_data <- tibble(year = test_yrs, ems_qty = seq(100, 200, length.out = length(test_yrs)), ems_unit = "tons/yr")
gg_annual_chart(chart_data) + geom_point()

library(inventory)

airport_cats <-
  tibble(cat_id = 441:708)

archived_emissions <-
  BY2011_annual %>%
  semi_join(airport_cats)

computed_emissions <-
  BY(2011) %>%
  area_source_projections() %>%
  semi_join(airport_cats) %>%
  speciate_PM() %>%
  speciate_TOG()

chart1_data <-
  archived_emissions %>%
  annual_emissions_by(cnty_abbr, pol_abbr, cat_id)

chart1_labels <- labs(
  title = "Airport Emissions",
  subtitle = "As archived",
  caption = "Basis: BY2011_annual")

chart1_data %>%
  group_by(cnty_abbr, cat_id) %>%
  gg_annual_chart() %>%
  add(geom_area(aes(fill = cnty_abbr))) %>%
  add(chart1_labels) %>%
  show()

chart2_data <-
  computed_emissions %>%
  arrange(cnty_abbr) %>%
  annual_emissions_by(cnty_abbr, cat_id, pol_abbr)

chart2_labels <- labs(
  title = "Airport Emissions",
  subtitle = "As computed today",
  caption = "Basis: BY(2011) %>% area_source_projections()")

chart2_data  %>%
  group_by(cnty_abbr, cat_id) %>%
  gg_annual_chart() %>%
  add(geom_area(aes(fill = cnty_abbr))) %>%
  add(chart2_labels) %>%
  show()


BAAQMD/ggtools documentation built on Feb. 8, 2023, 6:22 p.m.