Description Usage Arguments Details Value Author(s) Examples
Creates an oceanographic section plot from a data frame using ggplot2. Returns either an interpolated section or a bubble plot.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | section_plot(
df,
x,
y,
z,
bottom = NULL,
interpolate = FALSE,
interp_method = "mba",
log_y = FALSE,
xlab = "Distance",
ylab = "Depth",
zlab = "Variable",
ybreaks = waiver(),
xbreaks = waiver(),
zbreaks = waiver(),
contour = NULL,
contour_label_cex = 0.8,
contour_color = "white",
xlim = NULL,
ylim = NULL,
zlim = NULL,
zscale = "viridis",
zcolor = "black",
add_bottom = NULL,
sampling_indicator = "lines",
legend.position = "right",
base_size = 10,
...
)
|
df |
Data frame containing the data |
x |
Character specifying the column name which should be used as x (=distance) axis |
y |
Character specifying the column name which should be used as y (=depth) axis. The y axis will be inverted in the resulting plot. |
z |
Character specifying the column name which should be for bubbles or interpolation fill depending on the |
bottom |
Optional character specifying the column name which contains bottom depths OR a data frame with x-axis values in the first column and bottom depths in the second column. If provided, unique combinations of |
interpolate |
Logical indicating whether an interpolated section plot ( |
interp_method |
( |
log_y |
logical indicating whether the y-axis should be |
xlab, ylab, zlab |
Character specifying the labels for the x-axis, y-axis and legend, respectively. |
xbreaks, ybreaks, zbreaks |
Numeric vector specifying the breaks for the x-axis, y-axis and legend. See scale_continuous. |
contour |
( |
contour_label_cex |
Numeric giving the |
contour_color |
Character defining the color to be used for contour lines and labels. |
xlim, ylim |
Numeric vector of length two providing limits of the scale. Use NA to refer to the existing minimum or maximum. Use |
zlim |
Numeric vector of length two providing limits for fill or bubble size. Any values outside these limits will get the extreme values defined by |
zscale |
( |
zcolor |
( |
add_bottom |
Numeric vector of length two providing the depths that should be added to |
sampling_indicator |
(
|
legend.position |
Position for the ggplot legend. See the argument with the same name in theme. |
base_size |
Base size parameter for ggplot. See theme_bw. |
... |
Additional arguments passed to color and size scales. See |
Note that you can use the ggplot2 color and size scale arguments to adjust the scales as you want. Just place them inside the section_plot
function. See scale_colour_gradient2
, scale_colour_viridis_c
and scale_size
.
Returns either an interpolated section (geom_tile
) or a bubble (geom_point
) ggplot2 object.
Mikko Vihtakari
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Bubble plots
section_plot(df = chlorophyll[grepl("KpN.|Kb[0-4]", chlorophyll$Station),], x = "lon", y = "From",
z = "Chla")
# Interpolated CTD sections
## Standard temperature section plot. Difficult to see surface due to large differences in y-scale
section_plot(ctd_rijpfjord, x = "dist", y = "pressure", z = "temp", bottom = "bdepth",
interpolate = TRUE)
## Logarithmic y axis
section_plot(ctd_rijpfjord, x = "dist", y = "pressure", z = "temp", bottom = "bdepth",
interpolate = TRUE, log_y = TRUE)
## Contour lines
section_plot(ctd_rijpfjord, x = "dist", y = "pressure", z = "temp", bottom = "bdepth",
interpolate = TRUE, log_y = TRUE, contour = c(-1.8, 0, 1, 3))
## Duplicate values are averaged
df <- data.frame(X = rep(1:5, each = 3), Y = 1:3, Z = c(rep(0, 7), 2, rep(0, 7)))
section_plot(df, x = "X", y = "Y", z = "Z", interpolate = TRUE)
### Compare to:
section_plot(rbind(df, data.frame(X = 3, Y = 2, Z = 0)),
x = "X", y = "Y", z = "Z", interpolate = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.