sl.plot.points | R Documentation |
Plot points into a spheRlab plot.
sl.plot.points(plot.init.res, lon, lat, col = "black", pch = 1, ignore.visibility = FALSE, return.xy = FALSE)
plot.init.res |
a spheRlab plot specifics list as returned by |
lon |
a scalar, vector, or array with |
lat |
a scalar, vector, or array with |
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 |
If lon
and lat
contain no NAs, N
points are drawn (if visible).
This is one of the lowest-level plotting functions of spheRlab.
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.
Helge Goessling
sl.plot.lines
, sl.plot.polygon
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.