Closed
Thanks Achim. I agree that this is helpful and adds a disciplined "backend" for users that would like to pass customization arguments without having to go through the type_*() functions.
On that note, we'll also need to edit the first "breaking changes" item in NEWS here.
| Breaking changes: | |
| - As part of our new plot `type` logic (see below), character-based shortcuts | |
| like `type = "p"`, `type = "hist"`, etc. are reserved for default behaviour. | |
| In turn, this means that any type-specific arguments for customizing behaviour | |
| should no longer be passed through the main `tinyplot(...)` function (i.e., | |
| via `...`), since they will be ignored. Rather, these ancilliary arguments | |
| must now be passed explicitly as part of the corresponding `type_*()` function | |
| to the `type` argument. For example, say that you want to change the default | |
| number of breaks in a histogram plot. Whereas previously you could have called, | |
| say, `tinyplot(Nile, type = "hist", breaks = 30)`, now you should instead | |
| call `tinyplot(Nile, type = type_hist(breaks = 30))`. We're sorry for | |
| introducing a breaking change, but again this should only impact plots that | |
| deviate from the default behaviour. Taking a longer-term view, this new `type` | |
| logic ensures that users can better control how their plots behave, avoids | |
| guesswork on our side, and should help to reduce the overall maintenance burden | |
| of the package. |
Do you mind taking a crack at the re-wording? We can obviously move it out of breaking changes, since the old way will work again with your PR. But we should underscore that the documentation lives with the individual type functions and politely suggest that passing arguments through them (rather than ...) is the more idiomatic tinyplot way of doing things now.
EDIT: We should also update the documentation here to note that extra type-specific args can be passed through ....
| #' @param xaxs,yaxs,... other graphical parameters (see \code{\link[graphics]{par}}). |
Comment on lines +38 to 61
| if (is.character(type)) type = switch(type, | ||
| "points" = type_points, | ||
| "segments" = type_segments, | ||
| "area" = type_area, | ||
| "rect" = type_rect, | ||
| "polypath" = type_polypath, | ||
| "polygon" = type_polygon, | ||
| "pointrange" = type_pointrange, | ||
| "errorbar" = type_errorbar, | ||
| "boxplot" = type_boxplot, | ||
| "ribbon" = type_ribbon, | ||
| "histogram" = type_histogram, | ||
| "spineplot" = type_spineplot, | ||
| "qq" = type_qq, | ||
| "j" = type_jitter, | ||
| "jitter" = type_jitter, | ||
| "loess" = type_loess, | ||
| "ridge" = type_ridge, | ||
| "spline" = type_spline, | ||
| "glm" = type_glm, | ||
| "lm" = type_lm, | ||
| "function" = type_function, | ||
| type # Default case | ||
| ) |