tmap icon indicating copy to clipboard operation
tmap copied to clipboard

Document `tm_legend()` + add examples

Open olivroy opened this issue 5 months ago • 6 comments

I am trying to upgrade some code to v4, and I noticed that tm_legend() lacks documentation.

World |> 
  tm_shape() +
  tm_polygons(
    fill = "HPI",
    legend.format = list(
      fun = function(x) scales::dollar(x)
    )
  )

image

Furthermore, upgrading the previous code to v4 syntax is the following.

World |> 
  tm_shape() +
  tm_polygons(
    fill = "HPI",
    fill.scale = tm_scale(
      label.format = list(
      fun = function(x) scales::dollar(x)
    )
  ))

Is there a simpler way to do it?

I didn't get it on the first try as I attempted to do this first, but it didn't work (and didn't warn either)


World |> 
  tm_shape() +
  tm_polygons(
    fill = "HPI",
    fill.legend = tm_legend(
      format = list(
        fun = function(x) scales::dollar(x)
      )
    )
  )

olivroy avatar Sep 02 '24 19:09 olivroy