Knitting tmap runs causes all the map titles to end up on the first map

I am mystified by this one, and not even sure where to report it. When I create multiple tmap maps in a markdown document, and knit the document, all the titles (from tmap::tm_layout(title="Map xxx") )
end up on the first map.

Reprex here:

---
title: "tmap title problem"
author: "Alan Jackson"
date: "2022-12-13"
output: html_document
---
library(tidyverse)

#   Grad state boundaries as convenient polygon set
states <- USAboundaries::us_states(resolution = "low")

knitr::opts_chunk$set(echo = TRUE)

First map


tmap::tmap_mode("view") # set mode to interactive plots

tmap::tm_shape(states) +
  tmap::tm_polygons(alpha=0.3, col="geoid")+
  tmap::tm_scale_bar()+
  tmap::tmap_options(unit = "mi") +
  tmap::tm_layout(title="Map One")

second map


tmap::tmap_mode("view") # set mode to interactive plots

tmap::tm_shape(states) +
  tmap::tm_polygons(alpha=0.3, col="stusps")+
  tmap::tm_scale_bar()+
  tmap::tmap_options(unit = "mi") +
  tmap::tm_layout(title="Map Two")

image

Known bug for tmap, so I will close this.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.