# tm_grid

##### Coordinate grid lines

Creates a `tmap-element`

that draws coordinate grid lines. It serves as a layer that can be drawn anywhere between other layers. By default the coordinate system of the (master) shape object is used, which results in horizontal and vertical lines. Alternatively, grid lines can be reprojected, for instance to latitude longitude coordinates, and hence be curved.

##### Usage

```
tm_grid(x = NA, y = NA, n.x = NA, n.y = NA, projection = NA,
col = NA, lwd = 1, alpha = NA, labels.size = 0.6, labels.col = NA,
labels.rot = c(0, 0), labels.format = list(big.mark = ","),
labels.margin.x = 0, labels.margin.y = 0, labels.inside.frame = TRUE)
```

##### Arguments

- x
x coordinates for vertical grid lines. If

`NA`

, it is specified with a pretty scale and`n.x`

.- y
y coordinates for horizontal grid lines. If

`NA`

, it is specified with a pretty scale and`n.y`

.- n.x
prefered number of grid lines for the x axis.

- n.y
prefered number of grid lines for the y axis.

- projection
projection character. If specified, the grid lines are projected accordingly. See

`set_projection`

for projection details. Many world maps are projected, but still have latitude longitude (`"longlat"`

) grid lines.- col
color of the grid lines.

- lwd
line width of the grid lines

- alpha
alpha transparency of the grid lines. Number between 0 and 1. By default, the alpha transparency of

`col`

is taken.- labels.size
font size of the tick labels

- labels.col
font color of the tick labels

- labels.rot
Rotation angles of the labels. Vector of two values: the first is the rotation angle (in degrees) of the tick labels on the x axis and the second is the rotation angle of the tick labels on the y axis. Only

`0`

,`90`

,`180`

, and`270`

are valid values.- labels.format
list of formatting options for the grid labels. Parameters are:

- fun
Function to specify the labels. It should take a numeric vector, and should return a character vector of the same size. By default it is not specified. If specified, the list items

`scientific`

,`format`

, and`digits`

(see below) are not used.- scientific
Should the labels be formatted scientically? If so, square brackets are used, and the

`format`

of the numbers is`"g"`

. Otherwise,`format="f"`

, and`text.separator`

,`text.less.than`

, and`text.or.more`

are used. Also, the numbers are automatically rounded to millions or billions if applicable.- format
By default,

`"f"`

, i.e. the standard notation`xxx.xxx`

, is used. If`scientific=TRUE`

then`"g"`

, which means that numbers are formatted scientically, i.e.`n.dddE+nn`

if needed to save space.- digits
Number of digits after the decimal point if

`format="f"`

, and the number of significant digits otherwise.- ...
Other arguments passed on to

`formatC`

- labels.margin.x
margin between tick labels of x axis and the frame

- labels.margin.y
margin between tick labels of y axis and the frame

- labels.inside.frame
Show labels inside the frame?

*Documentation reproduced from package tmap, version 1.11, License: GPL-3*