knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", dpi = 300 )
The goal of ggoce is to provide a minimal set of ggplot2 components to make publication-quality plots of oce objects. It is currently under initial proof-of-concept development and should be used for entertainment purposes only.
You can install the development version from GitHub with:
# install.packages("remotes") remotes::install_github("paleolimbot/ggoce")
The ggoce package lets you pass 'oce' objects into ggplot2 functions as if they were data frames.
library(ggplot2) library(ggoce) theme_set(theme_oce()) data(ctd, package = "oce") ggplot(ctd, aes(x = salinity, y = depth)) + geom_point() + scale_y_reverse()
You can see the actual data frames that are generated by calling the fortify()
methods directly. The fortify()
methods are defined are for "ctd", "section", and "adp" objects.
data(ctd, package = "oce") data(section, package = "oce") data(adp, package = "oce") fortify(ctd) fortify(section) fortify(adp)
For "section" and "adp" objects, there is more than one data frame one might want to plot. To obtain these tables, call fortify()
directly and use the which
argument:
fortify(section, which = "metadata") fortify(section, which = "data") fortify(section, which = "combined") fortify(adp, which = "metadata") fortify(adp, which = "bottom_track") fortify(adp, which = "velocity")
The default methods for each of these are called when you pass it to ggplot()
and are chosen such that the variables you probably want to use are available:
ggplot(section, aes(distance, pressure)) + geom_point(aes(col = temperature)) + scale_y_reverse() + scale_colour_viridis_b()
ggplot(adp, aes(time, distance, fill = v)) + geom_raster() + facet_grid(vars(beam)) + scale_fill_gradient2(limits = function(x) c(-max(abs(x)), max(abs(x)))) + coord_cartesian(expand = FALSE)
The ggoce package provides geom_isopycnal()
to support creating standard temperture/salinity diagrams.
ggplot( ctd, aes( x = salinity, y = oce::swTheta( salinity, temperature, pressure ) ) ) + geom_isopycnal() + geom_point() + labs( x = "Practical salinity", y = "Potential Temperature (°C)" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.