cust.colorbar: defines colorbar settings for 'v.raster' and...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/cust.colorbar.r

Description

function (used by v) to define the colorbar placement and figure dimensions. Unlike set.colorbar the colorbar is not added to an existing plot but to a dummy device.

Usage

1
2
cust.colorbar(v_area, lon, lat, cbpos='', cbx, cby, 
              figdim, input.mode, force.figdim.widget=F, xpos=-1)

Arguments

region

region-keyword predefined by the region_definitions-dataset or an extent.

lon

Vector returning longitude coordinates of the area to be plotted.

lat

Vector returning latitude coordinates of the area to be plotted.

cbpos

letter ("b", "l", "t", "r") indicating the position of the colorbar (bottom, left, top, right). Overwrites cbx and cby values.

cbx

the horizontal limits (x1, x2) of the colorbar. If missing, the user will be asked for manual colorbar placement.

cby

the vertical limits (y1, y2) of the colorbar. If missing, the user will be asked for manual colorbar placement.

figdim

numeric vector indicating the width and height of the plot device in inches. If missing and force.figdim.widget is set FALSE, figdim is assigned a default width and height of 7in, otherwise the user will be asked to resize the plot device to set plot dimensions.

input.mode

character indicating the input mode of the function: 'i' for manual colorbar placement, 'v' for a vertical colorbar on the right side of the plot or 'h' for a hoizontal colorbar below the plot..

force.figdim.widget

whether figdim should be assigned by a widget if missing.

xpos

integer: initial position of the top left corner of the figure window on the pc-screen, given in pixels. Negative values are from the opposite corner. (default is -1). Disregarded under Mac OS.

Details

like set.colobar cust.colobar defines colorbar settings, but furthermore the default figure size. The function is used by calls of v on non-'.gz'-files and add.region.

Value

a list of colorbar definition vectors: cbx, cby, figdim and align of which the latter holds the values of gradient and oticks. See function argmuments for more details.

Author(s)

Robert K. Bauer

See Also

set.colorbar, add.region and v.raster

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Example:
path <- system.file("test_files", package="oceanmap")
nfiles <- Sys.glob(paste0(path,'/herring*.nc')) # load sample-'.nc'-files
head(nfiles)
rfile <- nc2raster(nfiles[1], varname='Conc', layer=1)

ext <- extent(rfile)
#cb <- cust.colorbar(ext) # starts new plot device to define colorbar placement
#cust.colorbar(ext, cbx=cb$cbx, cby=cb$cby) # if cbx and cby are given no figure is produced

#plotmap(ext)
#set.colorbar(cb$cbx, cb$cby) # plots to an existing plot

Example output

Loading required package: maps
Loading required package: mapdata
Loading required package: raster
Loading required package: sp
Loading required package: extrafont
Registering fonts with R
[1] "/usr/lib/R/site-library/oceanmap/test_files/herring_lavae.nc"
File /usr/lib/R/site-library/oceanmap/test_files/herring_lavae.nc (NC_FORMAT_CLASSIC):

     1 variables (excluding dimension variables):
        float Conc[lon,lat,time]   
            _FillValue: -1

     3 dimensions:
        lon  Size:352
        lat  Size:310
        time  Size:4   *** is unlimited ***
            units: seconds since 2006-03-01 00:00:00

converting matrix to RasterLayer

oceanmap documentation built on March 23, 2020, 5:06 p.m.