ts_plot: Temperature-salinity (T-S) plot from a data frame using...

View source: R/ts_plot.R

ts_plotR Documentation

Temperature-salinity (T-S) plot from a data frame using ggplot2

Description

Makes a T-S plot from salinity and temperature data.

Usage

ts_plot(
  dt,
  temp_col = "temp",
  sal_col = "sal",
  WM = kongsfjord_watermasses,
  color_wmpoly = "grey30",
  xlim = NULL,
  ylim = NULL,
  color = "watertype",
  zoom = TRUE,
  nlevels = 6,
  color_isopyc = "grey90",
  symbol_shape = 1,
  symbol_size = 3,
  symbol_alpha = 0.6,
  color_scale = NULL,
  color_var_name = NULL,
  margin_distr = FALSE,
  margin_width = 0.15,
  margin_height = 0.2,
  plot_data = TRUE,
  base_size = 10
)

Arguments

dt

data frame

temp_col

character specifying the column name that contains temperature information. Should be potential temperatures (theta) instead of in-situ tempretatures, if default WM is used.

sal_col

character specifying the column name that contains salinity information.

WM

dataframe containing the water type definitions for polygons boundaries for water types. Set to NULL to remove the polygon boundaries. See Details in define_water_type for further details.

color_wmpoly

character defining the color for water mass polygon edges.

xlim

numeric vector specifying th limits for x-axis. If NULL, the zoom argument is used.

ylim

numeric vector specifying th limits for y-axis. If NULL, the zoom argument is used.

color

character indicating the mapping variable for color. Either a single character from colors, "watertype" or column name in dt. If "watertype", the symbols are colored based on water type using a prededined palette. If the character specifies a valid color, that color is used for the data symbols.

zoom

logical indicating whether the x- and y-axis should be limited to data. If FALSE, the entire water mass diagram from the WM data frame is shown.

nlevels

number of automatically-selected isopycnal levels. Set to 0 to remove isopycnals.

color_isopyc

character defining the color for isopycnals.

symbol_shape

character or numeric. ggplot syntax for shape of plotting symbols. See geom_point

symbol_size

numeric. ggplot syntax for size of symbol. See geom_point

symbol_alpha

numeric value between 0 and 1 defining the transparency of symbols. Set to 1 to remove transparency. See geom_point

color_scale

named vector giving all WM$abb levels (names) and their corresponding colors. See the values argument in scale_colour_manual

color_var_name

character giving the name that should be used in legend of color scale. See the name argument in scale_colour_manual

margin_distr

logical indicating whether kernel density estimates of temperature and salinity should be added to margins of the plot.

margin_width, margin_height

numeric specifying the width and height of the x- and y-axis margin plots as a propotion of the plot width ("npc" from unit).

plot_data

logical indicating whether salinity and temperature data should be plotted. FALSE returns an empty T-S plot frame allowing further customization using ggplot2 syntax.

base_size

Base size parameter for ggplot. See theme_bw.

Author(s)

Mikko Vihtakari with help from baptiste to align marginal plots.

See Also

define_water_type, the kongsfjord_watermasses data.frame ,the rijpfjord_watermasses data.frame

Other ts_plot: ctd_kongsfjord, define_water_type(), kongsfjord_watermasses, rijpfjord_watermasses

Examples

# Using example data

dt <- data.frame(temp = c(1, -1.1, -0.8, 3.2), sal = c(34, 34.5, 34.9, 33.9))
ts_plot(dt)

# Using real CTD data

data("ctd_kongsfjord")

ts_plot(ctd_kongsfjord)
ts_plot(ctd_kongsfjord, zoom = FALSE) # show all of WM
ts_plot(ctd_kongsfjord, color = "area", margin_distr = TRUE) # scaling color to "area"
ts_plot(ctd_kongsfjord, color = "red", margin_distr = TRUE) # no color scaling

# Using a different WM

data("ctd_rijpfjord")

ts_plot(ctd_rijpfjord, WM = rijpfjord_watermasses)

# example of graphical parameter modification
ts_plot(ctd_rijpfjord, WM = rijpfjord_watermasses, symbol_shape = 16, symbol_size = 0.1, 
symbol_alpha = 0.8, margin_distr = TRUE, xlim = c(32, 35), color = "area") 

MikkoVihtakari/PlotSvalbard documentation built on July 12, 2022, 10:20 a.m.