Learn R Programming

oce (version 0.9-3)

plot.coastline: Plot a coastline

Description

Plot a coastline

Usage

## S3 method for class 'coastline':
plot(x,
     xlab="", ylab="",
     asp,
     clatitude, clongitude, span,
     expand=1,
     mgp=getOption("oceMgp"), 
     mar=c(mgp[1]+1,mgp[1]+1,1,1),
     bg,
     fill='lightgray',
     axes=TRUE, cex.axis=par('cex.axis'),
     add=FALSE, inset=FALSE,
     geographical=0,
     debug=getOption("oceDebug"),
     ...)

Arguments

x
A coastline object, as read by read.coastline or created by as.coastline, or a list containing items named latitud
xlab
label for x axis
ylab
label for y axis
asp
Aspect ratio for plot. The default is for plot.coastline to set the aspect ratio to give natural latitude-longitude scaling somewhere near the centre latitude on the plot. Often, it makes sense to set asp yours
clatitude
optional center latitude of map, in degrees north. If this and clongitude are provided, then any provided value of asp is ignored, and instead the plot aspect ratio is computed based on the center latitude. Al
clongitude
optional center longitude of map, in degrees east; see clatitude.
span
optional suggested span of plot, in kilometers. The suggestion is an upper limit on the scale; depending on the aspect ratio of the plotting device, the radius may be smaller than span. A value for span must b
expand
numerical factor for the expansion of plot limits, showing area outside the plot, e.g. if showing a ship track as a coastline, and then an actual coastline to show the ocean boundary. The value of expand is ignored if either
mgp
3-element numerical vector to use for par(mgp), and also for par(mar), computed from this. The default is tighter than the R default, in order to use more space for the data and less for the axes.
mar
value to be used with par("mar").
bg
optional colour to be used for the background of the map. This comes in handy for drawing insets (see details).
fill
colour to be used to fill land regions. This is ignored unless the coastline object is fillable (e.g. for a "shapefile" read by read.coastline). Set to NULL to turn off fil
axes
boolean, set to TRUE to plot axes.
cex.axis
value for axis font size factor.
add
boolean, set to TRUE to draw the coastline on an existing plot. Note that this retains the aspect ratio of that existing plot, so it is important to set that correctly, e.g. with asp=1/cos(lat * pi / 180),
inset
set to TRUE for use within plotInset. The effect is to prevent the present function from adjusting margins, which is necessary because margin adjustment is the basis for the meth
geographical
flag indicating the style of axes. If geographical=0, the axes are conventional, with decimal degrees as the unit, and negative signs indicating the southern and western hemispheres. If geographical=1, the sig
debug
set to TRUE to get debugging information during processing.
...
optional arguments passed to plotting functions. For example, set yaxp=c(-90,90,4) for a plot extending from pole to pole.

Value

  • None.

Details

This function plots a coastline. An attempt is made to fill the space of the plot, and this is done by limiting either the longitude range or the latitude range, as appropriate, by modifying the eastern or northern limit, as appropriate.

To get an inset map inside another map, draw the first map, do par(new=TRUE), and then call plot.coastline with a value of mar that moves the inset plot to a desired location on the existing plot, and with bg="white".

See Also

The documentation for coastline-class explains the structure of coastline objects, and also outlines the other functions dealing with them.

Examples

Run this code
library(oce)
data(coastlineWorld)
plot(coastlineWorld)
plot(coastlineWorld, clatitude=44.6, clongitude=-63.6, span=1000)
# Test code, examplifying how a new option could yield geographical labels
data(coastlineMaritimes)
plot(coastlineMaritimes, axes=FALSE, span=300)
x <- pretty(par('usr')[1:2], n=1.2*floor(par('fin')[1])) # the 1.2 bears some thinking; should cin be used?
y <- pretty(par('usr')[3:4], n=1.2*floor(par('fin')[2]))
box()
axis(side=1,at=x,labels=formatPosition(x,type='expression'))
axis(side=2,at=y,labels=formatPosition(y,type='expression'))

Run the code above in your browser using DataLab