-
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
bg.color in tm_text in v4, is it going to be replaced? #808
Comments
It will be a visual variable in v4. I just made a first implementation. I renamed the argument tm_shape(World) +
tm_text("name", bgcol = "green") tm_shape(World) +
tm_text("name", bgcol = "economy") Somehow, the boxes are a tad too wide, and as you can see the legend items have to be implemented accordingly. The implementation is in branch "bgcol". |
That's awesome, great to see progress. Might I suggest while you are doing it to add in a feature like ggrepel whereby boxes don't overlap? |
That would be great, but very hard to implement. Not sure ggrepel can be used for tmap, have to check. There is a similar function in tmap3, but much worse, so not sure whether to migrate or write a new implementation (or reuse ggrepel). Any help appreciated. |
Can I check, this is where you draw all the rectangles (?): grobTextBGList = mapply(function(x, y, w, h, b, a) {
rectGrob(x=x, y=y, width=w, height=h, gp=gpar(fill=b, alpha = a, col=NA))
}, tGX, tGY, tGW, tGH, bgcol, bgcol_alpha, SIMPLIFY = FALSE, USE.NAMES = FALSE) So I suppose what could be done prior to this call is:
It looks like ggrepel uses an iterated force algorithm and they call it repel_boxes2 this is written in C++ and interfaced using Rpp so it should be fairly straightforward to convert the tmap boxes into a format compatible with the algorithm and back. Based on looking at it for 2 minutes that is... I guess this would be the most direct way to do it and to reuse what has already been done. I've only briefly skimmed through your code but I guess it would make sense that I really want to try this out but I know I don't have time at the minute. I'm in such a debt to all the open-source developers out there. |
Merged the bgcol branch into master. @staropram About the repel feature:
|
To be continued in #850 |
Hi there, what happened to the bg.color parameter in V4 for say tm_text? It says this is now deprecated. How does one put a background color against text now?
The text was updated successfully, but these errors were encountered: