-
Notifications
You must be signed in to change notification settings - Fork 122
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
hyperlinks in text components (e.g. tm_credits) for pdf output #794
Comments
Good idea with that automatic text wrapping. I have written similar code from the treemap package that can be reused. |
I'm not sure if hyperlinks can be used. Is this possible in ggplot2? If so, we can use the same method, since they also rely on the grid graphics. |
Thanks @mtennekes. Could you share the code snippet from treemap to do this please? |
I found this link for ggplot2 that could be useful https://stackoverflow.com/questions/42259826/hyperlinking-text-in-a-ggplot2-visualization |
Implemented, but testing needed. So please test the following using the GH version: tm_shape(NLD_muni) + tm_borders("population") +
tm_credits("It will be great to create a textbox that is 0.2 of the enter map in Width. This box should be able to take a paragraph with many continuous lines without the use of line breaks using forward slash n in R" , col="gray45",fontfamily = "sans", fontface = "italic", bg.color =NA,bg.alpha = 0.9, position=c("left","bottom"), just = "left",width = 15) Note: in tmap4, the width of the components/legends is different. Rather than relative values (where 1 means the full map width), it is changed to absolute values, namely, lineheights. So the 15 in the example above means 15 lines of text. This may be a bit strange because we are measuring horizontal rather than vertical space, but on the other hand it is similar to the unit "em" in CSS and Latex. Thanks for the link of the hyperlink in ggplot2. Certainly useful, but a.t.m. this has low priority for me. |
Thanks, @mtennekes The continuous text withing the box worked. However, the line break (\n) worked sometimes and at other times, it ignored it. I assume it is because it is still in the testing phase. I noticed the legend default is now on the outside which is nice. Will it be possible to have independent controls for the different attributes outside instead of just the attr parameter please? When I add the frame = T parameter, the frame doesn't cover the entire text in the box.
|
Done :-) Please test @ar-onos |
Hi @mtennekes This works very well. I've also tried it using numeric positions. I noticed a new command: frame.r. Not sure what it does but I assigned a value to it for testing purposes:
|
You're welcome. |
I'm trying to insert a textbox on a map with a paragraph but I don't want the lines broken with "\n" in between the text except for a new paragraph. How do I achieve this with tmap, tm_credit or any other method please? Also can I insert a hyperlink in the tm_credit section for a map that will be saved as a pdf?
library(sf)
library(tmap)
This example shows what I mean under "Map Information"
The text was updated successfully, but these errors were encountered: