plot_map: Plot a map of the states with data using ggplot2::ggplot

View source: R/plot_map.R

plot_mapR Documentation

Plot a map of the states with data using ggplot2::ggplot

Description

Plot a map of the data and include the outline of the desired states. In theory, the data can be mapped on any state within the United States using an variable in the data frame.

Usage

plot_map(
  data,
  states = "california",
  yname = "total_catch_wt_kg",
  ytitle = "weight (kg)",
  yintercept = 34.5,
  alpha = 0.5,
  legend.position = c(0.9, 0.5)
)

Arguments

data

A data frame returned from nwfscSurvey::PullCatch.fn.

states

A single character value that will be used to search for regions in maps::map. Regex is allowed, e.g., "washington|oregon|california" will return the mainland of the US West Coast.

yname

A single character value providing the name of the response variable to include in the figure. Only values great than zero will be included.

ytitle

A single character value used to label the legend for the y variable.

yintercept

A numeric value for ggplot2::geom_hline. NULL will stop a horizontal line from being created.

alpha

Passed to ggplot2::geom_point to control the opacity of the points.

legend.position

A vector of two numeric values between zero and one that specify the relative location of the legend along the x and y axes. One can also use a single character value that is relevant to ggplot2::theme.

Value

A ggplot2::ggplot object.

Author(s)

Kelli F. Johnson

Examples

plot_map(
  data =data.frame(
    yy = 1:10,
    Latitude_dd = 41:50,
    Longitude_dd = rep(-121, 10)
  ),
  yname = "yy",
  states = "washington|oregon|california",
)


iantaylor-NOAA/Lingcod_2021 documentation built on Oct. 30, 2024, 6:42 p.m.