r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
868 stars 121 forks source link

Can labels plotted with tm_text be rotated 90°? #432

Closed JoMort closed 2 months ago

JoMort commented 4 years ago

I would like to rotate a label (in this map 'WALES'), but can't seem to find a function in tm_text to do this. Is it possible to rotate labels?

Exe estuary position

library(tmap)
library(maps)
library(sf)

# bbox
SEng = st_as_sfc(st_bbox(c(xmin= 301000, ymin= 5529126, xmax= 823743.9, ymax= 5900000), crs = st_crs(32630)))

# labels
LLabs <- data.frame(Location = c("WALES", "ENGLAND"),
                    X = c(-4.6, -1.7),
                    Y= c(52.25,  51.6))

LLabels <- st_as_sf(LLabs, 
                    coords = c('X', 'Y'),
                    crs = 4326)

minimap <- tm_shape(uk, bbox = SEng) +
  tm_polygons()+
  tm_shape(LLabels)+
  tm_symbols(col = "black", 
             size = 0, 
             shape = 18) +
  tm_text("Location", 
          xmod = 2, 
          size = 0.9)
mtennekes commented 4 years ago

Not yet possible, but should be nice to have.

olivroy commented 2 months ago

This is now possible with tmap v4, (not yet released, but can be installed with pak::pak("r-tmap/tmap"). tm_text() has an angle argument now.

using

  tm_text("Location", 
          xmod = 2,
         angle = 90, 
          size = 0.9)

works image