Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tm_text documentation for 3.3.4 inaccurate #881

Open
jonas-endter-optimax-energy opened this issue May 24, 2024 · 4 comments
Open

tm_text documentation for 3.3.4 inaccurate #881

jonas-endter-optimax-energy opened this issue May 24, 2024 · 4 comments
Labels
tmap_v3 v3 issues

Comments

@jonas-endter-optimax-energy

The tm_text documentation mentions a html.escape parameter for the tm_text function. This parameter does not seem to exist:
image
I as of yet have not found any method to add line breaks to tm_text and this would be the obvious method.

@mtennekes
Copy link
Member

Thanks for brining this up.

html.escape is item of legend.format, so you also find documentation mentioned there.
In tm_text you need to add legend.format = list(html.escape = TRUE). However, not sure if it also works for the text labels inside the map in v3.

Line breaks can probably be added with \n. This will work in plot mode, but not (yet) in view mode. At least in v4.

I also noticed that values.format could be handy for something like this:

World$x = paste(World$continent, "<br>", World$name)

tm_shape(World) +
    tm_polygons() +
    tm_text("x",
    text.scale = tm_scale_asis(values.format = list(html.escape = TRUE)))

@olivroy
Copy link
Contributor

olivroy commented May 29, 2024

@jonas-endter-optimax-energy, the docs is accurate! it just doesn't render correctly in rdocumentation.org.

In RStudio help pane, ?tmap::tm_text has html.escape documented in legend.format

image

I recommend reading the docs there or on the tmap site

@jonas-endter-optimax-energy
Copy link
Author

jonas-endter-optimax-energy commented May 29, 2024

sadly doing tmap::tm_text("text", legend.format = list(html.escape = FALSE)) does not work either and does not produce the expected behaviour in view mode
image
So maybe add to the documentation that this doesn't work in view mode?
(btw I also tested \n and it does not work either in view mode)

@jonas-endter-optimax-energy
Copy link
Author

it seems like the on site documentation has a decent number of arguments that don't do anything, like
bg.color (bg.alpha as well probably) and
shadow
this is the code that generates the text: tmap::tm_text("text" ,shadow = TRUE, bg.color = "#ffaaaa", bg.alpha = 1 ) and this is how it looks:
image
image

@mtennekes mtennekes added the tmap_v3 v3 issues label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tmap_v3 v3 issues
Projects
None yet
Development

No branches or pull requests

3 participants