Skip to content
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

Compound units fail #3

Closed
teunbrand opened this issue Jul 9, 2020 · 1 comment
Closed

Compound units fail #3

teunbrand opened this issue Jul 9, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@teunbrand
Copy link
Owner

teunbrand commented Jul 9, 2020

The following fails

library(ggplot2)
library(elementalist)

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  theme(axis.ticks = element_line_wiggle(1))
#> Error in xy[-nxy, , drop = FALSE] - xy[-1, , drop = FALSE]: non-numeric argument to binary operator

Most likely because I've been ignoring the existence of compound units, such as arithmetic units (e.g. unit(1, "cm") + unit(0.2, "npc")). I've checked this through the debug system. I don't know what the optimal solution is, but here are some thoughts:

  • Delay evaluating line manipulations until draw time. This allows me to convert to absolute units first and then apply manipulations. Downside is that there is no consistency in line manipulations anymore as the plot window is resized and it makes resizing slower.

  • If this is an edge case for the axis guide ticks, we could probably get away with solving this in the particular case of axis guides instead of solving the general case. The only other 'ticks'-case I can think of are the guide_colourbar() ticks, but these don't appear to be under the control of the theme system.

  • Get advice from someone smarter than me on how this can be solved best.

  • Error more gracefully

@teunbrand teunbrand added the bug Something isn't working label Jul 9, 2020
teunbrand added a commit that referenced this issue Jul 13, 2020
@teunbrand
Copy link
Owner Author

For now this is lazily fixed by having using guide_axis2() instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant