-
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
Free scale facet axes #253
Conversation
Merge branch 'main' into facet_free # Conflicts: # R/facet.R
- works with tinyAxis - assign and get facet usr pars through an env var (list)
Oh this is great! FYI, ggplot2 has
I've personally used the one-free-axis a lot, so if it's not too hard to implement I feel this would be important. |
Yeah, agree having separate support for freely varying x and y axes would be nice. I'll take a crack at it this evening. The other thing I haven't been able to resolve properly is free scaling for logged axes. This is more complicated than it first seems because of some internal magic that the |
Note to self (and potential future implementation): I've disabled support for free facet scales if the logged axes are detected. I just can't quite crack the implementation and don't have time to further pursue this right now. We can investigate at some future date. The tricky thing is that (re)setting if (par("xlog")) {
xfree = log(xfree)
xaxpf = par("xaxp")
xaxpf[3] = -abs(xaxpf[3])
par(xaxp = xaxpf)
}
if (par("ylog")) {
yfree = log(yfree)
yaxpf = par("yaxp")
yaxpf[3] = -abs(yaxpf[3])
par(yaxp = yaxpf)
} |
@grantmcdermott Can you put this one on hold? I need to completely refactor the |
To give you an idea, we can drop # axes, frame.plot and grid
if (isTRUE(axes)) {
args_x = list(x,
side = xside,
cex = get_tpar(c("cex.xaxs", "cex.axis"), 0.8),
col = get_tpar(c("col.xaxs", "col.axis"), "grey90"),
lwd = get_tpar(c("lwd.xaxs", "lwd.axis"), 0.5)
)
args_y = list(y,
side = yside,
cex = get_tpar(c("cex.yaxs", "cex.axis"), 0.8),
col = get_tpar(c("col.yaxs", "col.axis"), "grey90"),
lwd = get_tpar(c("lwd.yaxs", "lwd.axis"), 0.5)
)
type_range_x = type %in% c("pointrange", "errorbar", "ribbon", "boxplot", "p") && !is.null(xlabs)
type_range_y = isTRUE(flip) && type %in% c("pointrange", "errorbar", "ribbon", "boxplot", "p") && !is.null(ylabs)
if (type_range_x) {
args_x = modifyList(args_x, list(at = xlabs, labels = names(xlabs)))
}
if (type_range_y) {
args_y = modifyList(args_y, list(at = ylabs, labels = names(ylabs)))
}
if (isTRUE(frame.plot)) {
# if plot frame is true then print axes per normal...
do.call(Axis, args_x)
do.call(Axis, args_y)
} else {
# ... else only print the "outside" axes.
if (ii %in% oxaxis) do.call(Axis, args_x)
if (ii %in% oyaxis) do.call(Axis, args_y)
}
} |
Sure, I can hold off. Currently knocking my head against a wall trying to make separate "x" and "y" free scaling work. I keep running into a new bug each time I fix an old one, so I'm happy to take an enforced break. You may want to check with @zeileis, though since he was the original implementer of tinyAxis. IIRC it was necessary to support functionality like |
(Also: thanks for the HU about the potential conflict.) |
Unfortunately, I think none of the tests will pass because the I'll put |
Just as a quick comment, not sure that it is really relevant/helpful here: I mainly implemented In |
OK, that makes total sense. Thanks for clarifying. |
@vincentarelbundock I know we said pause work on this PR above, but now I'm wondering whether we shouldn't just merge as-is (after I move it out of draft)? While this doesn't give you separate x and y axis scaling, right now this PR imposes only a small change on the existing codebase. I think it will be easier to integrate these into your themes PR rather than the other way around. We can revisit separate free x and y scaling after themes. Agree? |
Yep, sounds good. I'm having problems with themes and have a crazy week, so it'll take a while. FYI, hooks for themes are difficult, because we often need to set a parameter that is used at the very start of |
All good and really appreciate you taking themes on. I think we should make themes the big feature for the next CRAN release cycle (i.e., after this one). So the timing should work out nicely. |
Or wait a couple weeks and make it a mega release with the and types. That would make a big splash, as they are the final two things that, for me, were needed to make this a daily driver. |
I definitely get the impulse. But my motivation here is partly strategic. I want to make sure that the new type system doesn't trigger any CRAN issues and avoid complicating this with a simultaneous themes/tpar refactor. Let me open a separate issue where we can discuss this, though. (After I get the kids too school.) |
- also fix cross-ref
Enables a
facet.args(free = TRUE)
argument.Closes #189.
Getting this to work properly requires some trickery behind the scenes to capture and reset
par(usr)
for each individual facet correctly. As explained in #90 (comment):But everything seems to be working correctly AFAICT.
MWEs
1.a) Points with fixed facets.
1.b) Points with free facets.
2.a) Histogram with fixed facets.
2.b) Histogram with free facets.