sl.plot.points: Plot Points

sl.plot.pointsR Documentation

Plot Points

Description

Plot points into a spheRlab plot.

Usage

sl.plot.points(plot.init.res, lon, lat, col = "black", pch = 1, ignore.visibility = FALSE, return.xy = FALSE)

Arguments

plot.init.res

a spheRlab plot specifics list as returned by sl.plot.init (or a variant thereof).

lon

a scalar, vector, or array with N elements specifying the longitudes of the points.

lat

a scalar, vector, or array with N elements specifying the latitudes of the points.

col

a colour (or a vector or array thereof). Can also be used to colour points according to a predefined colour scale, see example.

pch

a point 'character' (or a vector or array thereof).

ignore.visibility

a logical value indicating whether or not points shall be attempted to be drawn even if they are invisible, that is, outside the plot domain.

return.xy

a logical value indicating whether or not x-y-values of actually plotted points shall be returned. Can be useful e.g. for the creation of 2D histograms using sl.2D.hist.plot(). Default is FALSE. Not used for multi-part projections.

Details

If lon and lat contain no NAs, N points are drawn (if visible).

This is one of the lowest-level plotting functions of spheRlab.

Value

Nothin is returned, except if return.xy = TRUE, in which case a list with elements x and y providing the locttions of the plotted points in plot coordinates is returned.

Author(s)

Helge Goessling

See Also

sl.plot.lines, sl.plot.polygon

Examples

# initialise spheRlab plot
pir = sl.plot.init(projection = "polar", polar.latbound = 30, do.init.device = FALSE)

# plot some geographical info
sl.plot.lonlatgrid(pir, col = "grey", labels = TRUE, pole.hole = TRUE, labels.col = "darkgrey")
# use the following line (or similar) to plot coastlines (or other geo data); if the corresponding naturalearth
# dataset has not yet been loaded to the computer, this will invoke a download from naturalearthdata.com
# sl.plot.naturalearth(pir, what = "coastline", lines.col = "darkgrey", resolution = "coarse")

# generate evenly distributed random points on the sphere and plot them
Npnts = 1000
pnts = sl.xyz2lonlat(x = rnorm(Npnts), y = rnorm(Npnts), z = rnorm(Npnts))
sl.plot.points(pir, lon = pnts$lon, lat = pnts$lat, pch=4)

# now another random set of points, this time coloured by longitude
pnts2 = sl.xyz2lonlat(x = rnorm(Npnts), y = rnorm(Npnts), z = rnorm(Npnts))
cb = sl.colbar(cols=c("red","blue"),N=12)
col.inds = sl.num2colbar(pnts2$lon,colbar = cb)
# breaks can also be specified manually, which would actually make sense in this example so they are not so odd
sl.plot.points(pir,pnts2$lon,pnts2$lat,col = unlist(cb[col.inds$colour.index]),pch=16)
# the corresponding colourbar can be plotted with sl.plot.
# sl.plot.colbar(cb, breaks = col.inds$breaks, do.init.device = FALSE, labels.num = NULL)

# finish spheRlab plot
sl.plot.end(pir, do.close.device = FALSE)

helgegoessling/spheRlab documentation built on April 8, 2024, 8:34 a.m.