plot_map3: Plot a nice map with ggplot.

View source: R/plot_map3.R

plot_map3R Documentation

Plot a nice map with ggplot.

Description

Returns a cowplot object for a global map plot.

Usage

plot_map3(
  obj,
  maxval = NA,
  breaks = NA,
  lonmin = -180,
  lonmax = 180,
  latmin = -90,
  latmax = 90,
  nbin = 10,
  legend_title = waiver(),
  colorscale = viridis::viridis,
  do_reproj = FALSE,
  plot_title = waiver(),
  plot_subtitle = waiver(),
  combine = TRUE,
  varnam = NULL,
  ...
)

Arguments

obj

An object, either a RasterBrick (returned from a raster::brick() function call), or a list returned from a rbeni::read_nc_onefile() function call.

maxval

A numeric value specifying the maximum value for which the color key is to be extended. Defaults to NA (the 99% quantile of values is used).

breaks

A numeric vector specifying the breaks for the color scale. Defaults to NA, i.e. breaks are determined automatically based on nbin and maxval.

lonmin

Left edge (longitude, in degrees), defaults to -180.

lonmax

Right edge (longitude, in degrees), defaults to 180.

latmin

Lower edge (latitude, in degrees), defaults to -90.

latmax

Upper edge (latitude, in degrees), defaults to 90.

nbin

An integer specifying the number of bins used for the color key.

legend_title

A character string specifying the legend title (annotation above the color key)

colorscale

Either function that returns a set of colors or a vector of color names from which to interpolate. Defaults to virids::viridis.

do_reproj

A boolean specifying whether to re-project the map to Robin projection

plot_title

A character string specifying the plot title

plot_subtitle

A character string specifying the plot subtitle

combine

A boolean specifying whether the map and the colorscale should be combined using cowplot. Defaults to TRUE. If FALSE, a list of elements are retruned, where elements are the ggplot2 plot object and the coloscale object returned by the call to plot_discrete_cbar.

varnam

If obj is a rbeni-nc object (returned by read_nc_onefile()), varnam must be provided (a character string specifying the variable name in obj$vars[[varnam]]).

Value

A ggplot object for a global map plot.


stineb/rbeni documentation built on Feb. 24, 2023, 5:40 a.m.