Skip to content

Support direct labels#589

Open
grantmcdermott wants to merge 6 commits into
mainfrom
directlabs
Open

Support direct labels#589
grantmcdermott wants to merge 6 commits into
mainfrom
directlabs

Conversation

@grantmcdermott
Copy link
Copy Markdown
Owner

@grantmcdermott grantmcdermott commented May 16, 2026

From the user perspective, operationalised via legend = "direct". Best suited for line-based and/or x-ordered data.

pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
tinytheme("clean2")

aq = airquality
aq$Month = factor(month.name[aq$Month], levels = month.name[5:9])

plt(Temp ~ Day | Month, data = aq, type = "l", legend = "direct")

Margin spacing automatically adjusts based on the amount text that would otherwise be cliipped.

iris2 = iris
levels(iris2$Species) = c("A very long species name", "Medium", "Short")
plt(
  Sepal.Length ~ Petal.Length | Species, data = iris2,
  type = "lm",
  legend = "direct"
)

levels(iris2$Species) = rev(c("A very long species name", "Medium", "Short"))
plt(
  Sepal.Length ~ Petal.Length | Species, data = iris2,
  type = "lm",
  legend = "direct"
)

(Quite pleased with how this has turned out!)

@vincentarelbundock
Copy link
Copy Markdown
Collaborator

this is very cool!

Next step is to "repel" away from other elements? Maybe one day!

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.

2 participants