Skip to content

Conversation

@grantmcdermott
Copy link
Owner

@grantmcdermott grantmcdermott commented Nov 19, 2025

Fixes #511

pkgload::load_all("~/Documents/Projects/tinyplot")
#> ℹ Loading tinyplot
library(broom)

coefs = tidy(lm(mpg ~ wt + drat, mtcars), conf.int = TRUE)

plt(
  estimate ~ term,
  ymin = conf.low, ymax = conf.high,
  data = coefs,
  type = "errorbar",
  theme = "basic"
)
plt_add(type = 'hline')

Created on 2025-11-19 with reprex v2.1.1

Two notes:

  • The immediate solution to the above example is realizing that we don't need to calculate the axis limits again for secondary plots layers (i.e., where add = TRUE). We skip those cases now per cb6c156.
  • For the more general solution—not limited to add cases—I'm coercing to numeric before getting the axis range in lim.R. This seems to work fine and doesn't break any tests; partly because we already coerce character x and y variables to factors in sanitize_data.R. But I'm flagging it as a mental touch point in case it does end up breaking something down the line.

@grantmcdermott grantmcdermott changed the title coerce axis vars to numeric for range (test) Axis range for non-numeric vars Nov 19, 2025
@grantmcdermott grantmcdermott marked this pull request as ready for review November 20, 2025 00:11
@grantmcdermott grantmcdermott merged commit cabb7ec into main Nov 20, 2025
3 checks passed
@grantmcdermott grantmcdermott deleted the axis_factor_range branch November 20, 2025 00:18
grantmcdermott added a commit that referenced this pull request Nov 20, 2025
grantmcdermott added a commit that referenced this pull request Nov 20, 2025
* force legend eval to avoid downstream symbol (promise) issue

* also need list handler

* move `sanitize_legend` to own file while we're at it (like other sanitizers)

* fix test errors

* simplify sanitize_legend

* ancilliary simplification

* add test

* test for #513 while we're at it

* news
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.

Axis limits fail with factor variables

2 participants