Create PSRC TreeMap Chart
create_treemap_chart.Rd
This function allows you to create treemap charts.
Usage
create_treemap_chart(
t,
s,
fill,
title = NULL,
subtitle = NULL,
est = NULL,
dec = 0,
color = "psrc_light"
)
Arguments
- t
A tibble or dataframe in long form for plotting
- s
The name of the variable with the value you want to use to size the bar
- fill
The name of the variable you want the fill color of the bars to be based on
- title
Title to be used for chart, if desired - defaults to "NULL"
- subtitle
Sub-title to be used for chart, if desired - defaults to "NULL"
- est
Type for the numeric values - enter "percent", "currency" or "number", defaults to "percent"
- dec
Number of decimal points in labels - defaults to 0
- color
Name of color palette to use - generally defaults to "pgnobgy_5"
Examples
library(dplyr)
# Read in the example data and filter to Mode to Work for Everyone for all years in the data
df <- psrcplot::mode_share_example_data %>%
filter(Category=="Mode to Work by Race") %>%
filter(Geography=="Region" & Race=="Total") %>%
mutate(Year = as.character(Year)) %>%
filter(Year=="2020")
my.chart <- create_treemap_chart(t=df, s="share", fill="Mode", title="Mode Share to Work")