Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to fix #248, per promise here: https://bsky.app/profile/teunbrand.bsky.social/post/3lbkg6j53ec25.
Briefly, this is my proposal for a new theme element:
element_text_repel()
. This element brings that text repelling goodness to non-geom text.Allow me to walk through a few examples. First, let's make a synthetic plot that just shows the problem we're aiming to solve. The plot below has 3 text labels (in every direction) that are placed so closely together that they overlap.
When we replace all text labels with
element_text_repel()
, we see that most of the text is repelled. However, the connection from the text to their points of origin, and text justification, is terrible. The legend doesn't have points of origin, so the text there isn't dodged (and probably doesn't need to be dodged).We can fix these horrible line connections by allow for a little bit more space through the
margin
setting. Also, for the secondary axes, we need to set theposition
, as it can't be automatically guessed from the context.Created on 2024-12-02 with reprex v2.1.1