-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Feature request: rich text in labels (like ggtext) #169
Comments
Thanks for opening the issue! This is also on my wishlist. I would be very happy to review a pull request if anyone wants to give it a shot. Otherwise, I might eventually find some time to try this some day. |
@slowkow Per the discussion here, you could directly support ggtext by making the text grob drawing function configurable. Something like, |
@slowkow What about factoring out the code and exporting the repulsion code so that it would be easy to build geoms for different kinds of grobs. (Just dreaming... but adding geom_plot_repel(), geom_table_repel() and geom_grob_repel() to 'ggpmisc' for use on maps and time lines would be very useful...) I need to have a look at the code in 'ggrepel', but you know it better... Does this seem feasible? a repulsion function that takes a list or tree of grobs as input and returns a list or tree of grobs at the new postions? |
@cbrueffer I think that issue is focused on trying to get some repel functionality for plots created with base grid graphics (without ggplot2). @aphalo I like the idea, but I need to think about whether it is feasible. My first thought about your comment is copying the functionality of My current understanding is that we probably need to make a new I'm not sure what would go in By the way, sometimes it may be easier to copy internal ggrepel code and make a fresh new package instead of trying to figure out how to make it a dependency. This will vary from case to case, but it is worth considering as an option. |
@slowkow Thanks for the detailed answer! Yes, I fully agree that we need to write these geoms individually. I would not use |
Related discussion: https://twitter.com/ClausWilke/status/1245783222283374593. Also see this snippet from a direct reply to the above tweet (though I would prefer that we specify string as in From the user perspective I would like to have consistent experience when specifying grob handling the text when using different ggplot extensions. Would it be worth consulting Claus Wilke and Thomas Lin Pedersen on the preferred API? |
@aphalo @slowkow This idea of separating out the repulsion seems like a very good idea. Given Perhaps there's some trivial other modification I've missed (the inner workings of grid/ggplot2 are not very familiar to me). But, it seems to me, if the repulsion (and grob juggling) was abstracted away from the main geom, so any geom could call it, then that would make the modification to Plus, it would then make @clauswilke idea of allowing functions to have a |
Checking in to see if anyone has progressed this idea and to further express interest in being able to use rich text in combination with ggrepel. |
Pull requests are welcome! I would be happy to review a pull request that implements this feature. |
Summary
As requested by @cbrueffer and discussed in #145, ggtext is now on CRAN. It would be wonderful to be able to plot "repelled" labels that are formatted with markup, for example with something like
geom_richtext_repel()
andgeom_textbox_repel()
.I thought of this today as I'm plotting nounphrases in which I replaced spaces with "<br>" so the words wrap on the plot.
The text was updated successfully, but these errors were encountered: