plotPresGrid | R Documentation |
Creates a grid plot of the presence or density of detections across time where the x-axis is the hour of the day and the y-axis is the date
plotPresGrid(
x,
start = NULL,
end = NULL,
bin = c("hour", "minute", "30min", "15min"),
type = c("presence", "density"),
by = NULL,
alpha = 0.5,
gps = NULL,
format = c("%m/%d/%Y %H:%M:%S", "%m-%d-%Y %H:%M:%S",
"%Y/%m/%d %H:%M:%S", "%Y-%m-%d %H:%M:%S"),
fill = "blue",
color = NA,
cmap = viridis_pal()(25),
title = TRUE,
plotTz = "UTC"
)
x |
a data.frame of detections, must have a column |
start |
the beginning datetime of the plot, if |
end |
the ending datetime of the plot, if |
bin |
the unit of time for each rectangle in the grid, must be one of "hour", "minute", "30min", or "15min" |
type |
one of either "presence" or "density". If "density", then boxes will be colored according
to the number of detections in each |
by |
(optional) if not |
alpha |
opacity of rectangles, only used if |
gps |
(optional) if not |
format |
date format if |
fill |
the fill color for the boxes, only used if |
color |
the outline color for the boxes, only used if |
cmap |
the colormap to use for the boxes, only used if |
title |
if |
plotTz |
the timezone to use for plotting the data. Note that inputs must still be in UTC, this option allows you to create plots scaled to local time. Valid values come from OlsonNames |
a ggplot2 object
Taiki Sakai taiki.sakai@noaa.gov
df <- data.frame(UTC = as.POSIXct(runif(1e2, min=0, max=7*24*3600),
origin='1970-01-01 00:00:00', tz='UTC'),
label = sample(letters[1:3], 1e2, replace=TRUE))
plotPresGrid(df, type='presence', bin='hour')
plotPresGrid(df, type='density', bin='hour')
plotPresGrid(df, type='density', bin='30min')
gps <- data.frame(UTC = as.POSIXct('1970-01-01 00:00:00', tz='UTC'),
Latitude=32.4,
Longitude = -118)
plotPresGrid(df, gps=gps, bin='hour')
# coloring presence grid by label column
plotPresGrid(df, gps=gps, by='label')
# can be confusing if there is a lot of overlap, ggplot output can be split
library(ggplot2)
plotPresGrid(df, gps=gps, by='label') + facet_wrap(vars(label), ncol=2)
# using "by" with type="density" defaults to this facet_wrap behavior
# since color is already being used to represent density
plotPresGrid(df, gps=gps, by='label', type='density')
# can adjust facet_wrap parameters by adding it again
plotPresGrid(df, gps=gps, by='label', type='density') + facet_wrap(vars(label), ncol=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.