tmap icon indicating copy to clipboard operation
tmap copied to clipboard

Wrong v3 code translation

Open olivroy opened this issue 1 year ago • 7 comments
trafficstars

tmap_mode("view")
	m <- tm_shape(NLD_muni) +
		     tm_fill(col="population", convert2density=TRUE, 
                 style="kmeans", 
                 title=expression("Population (per " * km^2 * ")")) +
		     tm_borders("black", alpha=.5) + 
		 tm_shape(NLD_prov) +
		     tm_borders("grey25", lwd=2) +
		tm_style("classic") +
		tm_format("NLD", inner.margins = c(.02, .15, .06, .15)) + 
	    tm_scale_bar(position = c("left", "bottom")) +
	    tm_compass(position=c("right", "bottom"))

V4: Nice addition of the compass in "view" mode image

  • ~legend title not passed correctly.~
  • ~style = "k-means" not passed correctly or maybe convert2density.~
  • popups not treated the same?
  • ~In plot mode, the compass looked better in v3?~ V4 patched! image

V3 image

  • the basemap control doesn't work in v3 anyway

olivroy avatar Apr 09 '24 18:04 olivroy

Nice catch. Several issues here. Also col should be redirected to fill visual variable.

mtennekes avatar Apr 10 '24 07:04 mtennekes

thank you for your work I know it is a lot of small details.

Wish I could help more with the barebones

olivroy avatar Apr 10 '24 11:04 olivroy

example works in plot mode. Note that the style "classic_v3" is required rather than "classic". I could automatically switch to a _v3 style in case v3 code is detected in another tmap element.

To do for view mode:

  • popups
  • sepia colors for layer selection box and zoom buttons, and background in general.

mtennekes avatar Apr 10 '24 16:04 mtennekes

I could automatically switch to a _v3 style in case v3 code is detected in another tmap element.

I think it is not necessary.. Maybe others will have different opinions, my main concern is more about getting the data right, rather than exact color or styling!

Looks fantastic with your most recent fix! image

image

olivroy avatar Apr 10 '24 16:04 olivroy

Code translation improved. Please check

mtennekes avatar Apr 26 '24 20:04 mtennekes

Hi @mtennekes , thanks for working on this!

Seems like there are still issues on main as of this commit 8fc35ffacab8b02847b4f09f26ea5aa1847040b2

The example I provided in the initial comment errored

Error is

Erreur dans FUN(X[[i]], ...) : objet 'km' not found

Also, the title and breaks are not passed correctly. (it worked in a previous dev version)

image

olivroy avatar Apr 30 '24 18:04 olivroy

The first example is working again!

Not sure though if it does not break other examples... In order to make the expression title work I had to replace list to alist (e.g. in https://github.com/r-tmap/tmap/blob/93554e8aab332a9b607e367283e4fbd0e62d8750/R/tm_layers_polygons.R#L238)

mtennekes avatar May 01 '24 05:05 mtennekes

Thanks! The build is not working currently (Unknown exports tm_donut() and opt_tm_donut(). Maybe check_man() should be run again

olivroy avatar May 01 '24 12:05 olivroy

Thanks! The build is not working currently (Unknown exports tm_donut() and opt_tm_donut(). Maybe check_man() should be run again

See #869 , should be fixed

mtennekes avatar May 01 '24 18:05 mtennekes

Looking good, thanks!

I think we can close this one

View image

Plot image

olivroy avatar May 02 '24 15:05 olivroy