-
Notifications
You must be signed in to change notification settings - Fork 12
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
draw
argument
#245
draw
argument
#245
Conversation
Do we need to expose this to users? We could have a Then, |
Hmmm, I have a feeling you're going to warn me against argument proliferation... but I don't necessarily see this as an either-or situation. I think we could add For example, sometimes I just want to add text annotation to a plot and this requires a different logic to passing labels through a data frame (which I imagine is what pkgload::load_all(("~/Documents/Projects/tinyplot"))
#> ℹ Loading tinyplot
plt(
Temp ~ Day, facet = ~Month, data = airquality,
draw = {
abline(h = 80, lty = 2)
text(5, 80, "Hot", adj = 1, col = "red", pos = 3)
text(5, 80, "Cold", adj = 1, col = "blue", pos = 1)
}
) Created on 2024-11-07 with reprex v2.1.1 |
lol, yeah. I have a reputation now ;-) I will say that, in this case, I can see the motivation. What is cool about |
Yeah, exactly. I think that this could open up a bunch of cool features and flexibility. Two quick additional examples to underscore the point:
tpar(pch = 19)
plt(
mpg ~ wt, data = mtcars, facet = ~am, legend = FALSE, #axes = "l",
draw = legend("topright", legend = as.roman(ii), bg = "lightcyan", x.intersp = 0)
)
data("penguins", package = "palmerpenguins")
plt(
bill_length_mm ~ body_mass_g | species, data = penguins, facet = "by", legend = FALSE, axes = "l",
draw = plt(bill_length_mm ~ body_mass_g , data = penguins, add = TRUE, col = "lightgray")
) I'll add a few more examples to to the docs and then we can review again. Question: One potential downside is that the |
What happens if they use |
The penguins example is cool, very nice! |
Minor update. I'm going to wait for #246 to be merged first, since I'll build on some changes/docs forthcoming that PR. |
Closes #236.
Adds a new
draw
argument that allows users to pass drawing functions that are simply captured and evaluated directly.One nice feature is that you can leverage the internal facet looping counter (namely:
ii
) to construct programmatic drawings.