这是indexloc提供的服务,不要输入任何密码
Skip to content

tm_inset with tmap object #1148

@andrewmaclachlan

Description

@andrewmaclachlan

Hi, i am struggling to get tm_inset() to work with a tmap object. It works with a bounding box and ggplot object but not a tmap object - https://r-tmap.github.io/tmap/reference/tm_inset.html

Am i missing something or is this a bug?

For example - tmap object, does not show

#inset object
inset <- tm_shape(World)+
  tm_polygons()

tm_shape(NLD_dist) +
  tm_polygons(
    fill = "dwelling_value",
    fill.scale = tm_scale_continuous_pseudo_log(values = "-cols4all.pu_gn_div"),
    col = NULL) +
tm_shape(NLD_muni) +
  tm_borders(col = "black", lwd = 0.5) +
tm_shape(NLD_prov) +
  tm_borders(col = "black", lwd = 1.5) +
#add inset map
tm_inset(inset , height = 12, width = 12, position = c("left", "top")) +
  tm_compass(position = c("left", "top"), )

ggplot2 object, works fine.

 p = ggplot(World, aes(x = gender, y = press, colour = continent)) +
    geom_point() +
    theme_bw()

tm_shape(NLD_dist) +
  tm_polygons(
    fill = "dwelling_value",
    fill.scale = tm_scale_continuous_pseudo_log(values = "-cols4all.pu_gn_div"),
    col = NULL) +
tm_shape(NLD_muni) +
  tm_borders(col = "black", lwd = 0.5) +
tm_shape(NLD_prov) +
  tm_borders(col = "black", lwd = 1.5) +
tm_inset(p, height = 12, width = 12, position = c("left", "top")) +
  tm_compass(position = c("left", "top"), )

Thanks,

Andy

Metadata

Metadata

Assignees

Labels

LayoutIssues related to map layout (including many maps, facets, positions, etc.)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions