map_ng | R Documentation |
Maps of the Federal Republic of Nigeria that are based on the basic plotting idiom utilised by maps:map and its variants.
map_ng(
region = character(),
data = NULL,
x = NULL,
y = NULL,
breaks = NULL,
categories = NULL,
excluded = NULL,
exclude.fill = NULL,
title = NULL,
caption = NULL,
show.neighbours = FALSE,
show.text = FALSE,
legend.text = NULL,
leg.title,
plot = TRUE,
...
)
region |
A character vector of regions to be displayed. This could be States or Local Government Areas. |
data |
An object containing data, principally the variables required to plot in a map. |
x , y |
Numeric object or factor (or coercible to one). See Details. |
breaks |
Numeric. A vector of length >= 1. If a single value i.e.
scalar, it denotes the expected number of breaks. Internally, the function
will attempt to compute appropriate category sizes or fail if out-of bounds.
Where length is >= 3L, it is expected to be an arithmetic sequence that
represents category bounds as for |
categories |
The legend for the choropleth-plotted categories. If not defined, internally created labels are used. |
excluded |
Regions to be excluded from a choropleth map. |
exclude.fill |
Colour-shading to be used to indicate |
title , caption |
An optional string for annotating the map. |
show.neighbours |
Logical; |
show.text |
Logical. Whether to display the labels of regions. |
legend.text |
Logical (whether to show the legend) or character vector
(actual strings for the legend). The latter will override whatever is
provided by |
leg.title |
String. The legend title. If missing, a default value is
acquired from the data. To turn off the legend title, pass |
plot |
Logical. Turn actual plotting of the map off or on. |
... |
Further arguments passed to |
The default value for region
is to print all State
boundaries.
data
enables the extraction of data for plotting from an object
of class data.frame
. Columns containing regions (i.e. States as well
as supported sub-national jurisdictions) are identified. The argument also
provides context for quasiquotation when providing the x
and
y
arguments.
For x
and y
, when both arguments are supplied, they are taken
to be point coordinates, where x
represent longitude and y
latitude. If only x
is supplied, it is assumed that the intention of
the user is to make a choropleth map, and thus, numeric vector arguments are
converted into factors i.e. number classes. Otherwise factors or any object
that can be coerced to a factor should be used.
For plain plots, the col
argument works the same as with
map
. For choropleth maps, the colour provided represents
a (sequential) colour palette based on RColorBrewer::brewer.pal
. The
available colour options can be checked with
getOption("choropleth.colours")
and this can also be modified by the
user.
If the default legend is unsatisfactory, it is recommended that the user
sets the legend.text
argument to FALSE
; the next function
call should be legend
which will enable finer
control over the legend.
An object of class sf
, which is a standard format containing
the data used to draw the map and thus can be used by this and other
popular R packages to visualize the spatial data.
When adjusting the default colour choices for choropleth maps, it is
advisable to use one of the sequential palettes. For a list of of available
palettes, especially for more advanced use, review
RColorBrewer::display.brewer.all
.
vignette("nigeria-maps")
for additional ways to use this
function.
## Not run:
map_ng() # Draw a map with default settings
map_ng(states("sw"))
map_ng("Kano")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.