Generates a plot of measurements from depth profile data

plot_depth(
  data,
  col_datetime,
  col_depth,
  col_measure,
  lab_datetime = NA,
  lab_depth = NA,
  lab_measure = NA,
  lab_title = NA
)

Arguments

data

data frame of site id (optional), date/time, depth , and measurement (e.g., temperature).

col_datetime

Column name, Date Time

col_depth

Column name, Depth

col_measure

Column name, measurement for plotting

lab_datetime

Plot label for x-axis, Default = col_datetime

lab_depth

Plot label for legend, Default = col_depth

lab_measure

Plot label for y-axis, Default = col_measure

lab_title

Plot title, Default = NA

Value

a ggplot object

Details

Can be used with any parameter. A plot is returned that can be saved with ggsave(filename).

Labels (and title) are function input parameters. If they are not used the plot will not be modified.

The default theme is black and white.

The returned object is a ggplot object so it can be further manipulated.

Examples

# Data (Test Lake)
data         <- laketest

# Column Names
col_datetime <- "Date.Time"
col_depth    <- "Depth"
col_measure  <- "temp_F"

# Plot Labels
lab_datetime <- "Date Time"
lab_depth    <- "Depth (m)"
lab_measure  <- "Temperature (F)"
lab_title    <- "Test Lake"

# Create Plot
p_profile <- plot_depth(data = data
                        , col_datetime = col_datetime
                        , col_depth = col_depth
                        , col_measure = col_measure
                        , lab_datetime = lab_datetime
                        , lab_depth = lab_depth
                        , lab_measure = lab_measure
                        , lab_title = lab_title)

# Print Plot
print(p_profile)


# Demo ability to tweak the plot
p_profile + ggplot2::geom_hline(yintercept = 65
                               , linetype = "dashed"
                               , color = "red") +
    ggplot2::labs(caption = "Red dashed line = User defined value")


# save plot to temp directory
tempdir() # show the temp directory
#> [1] "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//Rtmp2bBrgJ"
ggplot2::ggsave(file.path(tempdir(), "TestLake_tempF_plotDepth.png"))
#> Saving 6.67 x 6.67 in image