Skip to content

repel text#621

Open
grantmcdermott wants to merge 3 commits into
mainfrom
type_text-repel
Open

repel text#621
grantmcdermott wants to merge 3 commits into
mainfrom
type_text-repel

Conversation

@grantmcdermott

Copy link
Copy Markdown
Owner

Partially closes #318. Builds on the same repel.R function that was introduced in the direct labels PR (#589)

pkgload::load_all("~/Documents/Projects/tinyplot")
#> ℹ Loading tinyplot
tinyplot(mpg ~ wt, data = mtcars,
  type = type_text(labels = row.names(mtcars), xpd = NA))

versus

tinyplot(mpg ~ wt, data = mtcars,
  type = type_text(labels = row.names(mtcars), xpd = NA, repel = TRUE))

Two limitations:

  1. We don't adjust the plot region and margins in response to the text width or height (but that's a pre-existing issue).

  2. The repulsion logic operates at the group level. So, while we can guarantee that text will be dodged within groups, there may still be overlaps across groups. (Fixing this requires a more heavy-handed change to the code and will likely necessitate a second pass through the main tinyplot.R code. So I'm not sure it's worth it.)

tinyplot(mpg ~ wt | factor(cyl), data = mtcars,
  type = type_text(labels = row.names(mtcars), xpd = NA, repel = TRUE, ))

Created on 2026-06-10 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repel option for type_text()?

1 participant