aqiColors: Generate AQI Colors

Description Usage Arguments Value Examples

View source: R/aqiColors.R

Description

This function uses the leaflet::colorBin() function to return a vector or matrix of colors derived from PM2.5 values.

Usage

1
2
3
4
5
6
7
aqiColors(
  x,
  palette = AQI$colors,
  domain = c(0, 1e+06),
  bins = AQI$breaks_24,
  na.color = NA
)

Arguments

x

vector or matrix of PM2.5 values or a ws_monitor object

palette

color palette (see leaflet::colorBin())

domain

range of valid data (see leaflet::colorBin())

bins

color bins (see leaflet::colorBin())

na.color

missing value color (see leaflet::colorBin())

Value

A vector or matrix of AQI colors to be used in maps and plots.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
wa <- monitor_subset(Northwest_Megafires, stateCodes='WA', tlim=c(20150821,20150828))
colorMatrix <- aqiColors(wa)
time <- wa$data$datetime
pm25 <- wa$data[,-1]
plot(time, pm25[,1], col=colorMatrix[,1],
     ylim=range(pm25, na.rm=TRUE),
     xlab="2015", ylab="PM 2.5 (ug/m3)", main="Washington State Smoke")
for ( i in seq_along(pm25) ) {
  points(time, pm25[,i], col=colorMatrix[,i], pch=16)
}

PWFSLSmoke documentation built on Nov. 23, 2021, 5:06 p.m.