add_points: add_points

Description Usage Arguments Value Author(s) See Also

View source: R/add_points.r

Description

This function adds points to an existing plot. The advantage over points(...) is that by including a map object as input, it will automatically reproject the points, and trim them such that only positions that fall within the map boundaries are shown. The user is notified of how many positions lay outside of the map boundaries. Additionally, the input data can either be symbolized generically (i.e. one style), or if a bin.style is elected, data will be symbolized according to the values of an identified field. Both the colour and size of the points can vary with the values in plot.field.

Usage

1
2
3
4
5
6
7
8
add_points(df, basemap = NULL, lat.field = "LATITUDE",
  lon.field = "LONGITUDE", plot.field = NULL, plot.field.pretty = NULL,
  pnt.style = 21, pnt.fill = "#1874CD", pnt.outline = "#333333",
  pnt.cex.min = 1, pnt.cex.max = 2, show.legend = TRUE,
  leg.pos = "topleft", colour.ramp = c("#edf8b1", "#7fcdbb", "#2c7fb8"),
  size.ramp = TRUE, bin.style = "fixed", fixed.breaks.bins = c(1, 4, 32,
  256, 2045, 16336, 130496, 1042432, 8327186), trim.fixed.breaks = TRUE,
  trim.legend = TRUE, nbins = 3, save.plot = FALSE)

Arguments

df

the dataframe to be plotted

basemap

a SpatialPolygons object (identifying the boundaries and projection of an existing plot). If none is provided, a default make_basemap() object will be used. object

lat.field

the default is 'LATITUDE'. The name of the field holding latitude values (in decimal degrees).

lon.field

the default is 'LONGITUDE'. The name of the field holding longitude values (in decimal degrees).

plot.field

the default is 'EST_COMBINED_WT'. The field on which to symbolize the data. If unspecified, the data can only be symbolized generically.

plot.field.pretty

the default is NULL. Applies only when bin.style = F. This is a nice name to describe plot.field which will be displayed in the legend.

pnt.style

the default is 21. Determines the style of the points (any valid value for pch is acceptable).

pnt.fill

the default is 'red'. Applies only when show.legend = T. Determines the colour of the points.

pnt.outline

the default is 'black'. This determines the colour outlining the points.

pnt.cex.min

the default is 1. When bin.style = F, this determines the size of the points, and when bin.style = T, this determines the minimum size of the points to be drawn.

pnt.cex.max

the default is 2. When bin.style = F, this is ignored, and when bin.style = T, this determines the maximum size of the points to be drawn.

show.legend

the default is FALSE. Determines whether or not a legend will be displayed.

leg.pos

the default is 'topleft'. Determines where on the plot the legend will be displayed (if show.legend=TRUE). Valid values are 'topleft','topright','bottomleft','bottomright'.

colour.ramp

the default is c("#edf8b1", "#7fcdbb", "#2c7fb8"), which is color-blind friendly. If this vector exists, data will be symbolized along a gradient of colours as the values in 'plot.field' increase. Otherwise, all data will be symbolized as the value selected for 'pnt.fill'. You can use hex values, or colour names (e.g. c('blue','pink')), but there must be at least 2 colour present.

size.ramp

the default is TRUE this indicates whether or not the point size should increase with increasing values of plot.field

bin.style

the default is fixed chosen style: one of "NULL", fixed", "sd", "equal", "pretty", "quantile", "kmeans", "hclust", "bclust", "fisher", or "jenks". If NULL, all points will be displayed identically, but if a grouping style is selected, the data points will be grouped according to the values in plot.field.

fixed.breaks.bins

the default is c(1,100,1000,100000) if the bin.style is set to "fixed", a vector of the desired upper ends of the desired breaks must be supplied (e.g. c(2, 5, 10, 100, 500.10000, 100000))

trim.fixed.breaks

the default is TRUE In cases where the fixed.breaks.bins vector extends beyond the data values, this parameter removes unused categories so that the largest values receive the maximum symbology (i.e. largest pnt.cex.max and extreme colour.ramp colour)

trim.legend

the default is TRUE This ensure that only values that exist in the data are shown in the legend.

nbins

the default is 3. Applies only when a bin.style is selected. Determines how many "bins" to use to display the data.

save.plot

the default is FALSE. If FALSE, the plot is displayed, if TRUE, it is saved to the working directory as a bio.plotting.png.

Value

a SpatialPolygons object (identifying the boundaries and projection of an existing plot). It also notifies the user of how many positions lay outside of the map boundaries.

Author(s)

Mike McMahon, Mike.McMahon@dfo-mpo.gc.ca

See Also

Other plotting: df_qc_spatial, make_basemap


Beothuk/bio.plotting documentation built on May 5, 2019, 1:36 p.m.