-
Notifications
You must be signed in to change notification settings - Fork 2
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
get_dims should handle cases where height or width is fully determined #9
Comments
While this issue isn't the same as what started this issue thread, it falls in line with the issue title. (This is both an issue and a solution.) I recently answered a question on SO. The questioner was looking for a function like Here's the code for
This function could then be used in R Markdown. Note that the second chunk has dynamic chunk options.
|
This is very cool! I hadn't thought of either the mapping or Rmarkdown use cases for this, but I'm glad this turned out to be useful for them. As you probably noticed, I don't maintain this package actively anymore and I know that ggplot has changed a lot since I last tested Since it's been so long (and the package has no test coverage to help me remember :( ), I no longer remember whether there were cases that would fail without that initial check or if it was solely to allow returning early in cases where we knew before doing any work that the answer was going to be [maxheight, maxwidth]. If it's the latter, adding your changes into the package will be a win for everyone. @fraupflaume would you be willing to turn this into formal PR? I'm happy to review and help test it. |
It is possible, though maybe rare in practice, for a Grid layout to contain nulls in the heights but not the widths or vice versa. The concept behind
get_dims
still applies in these cases, but we need to handle it explicitly. Current version throws "subscript out of bounds" when it discovers there are 0 elements inpanel_asps
.I started work on this in 7315e1d but gave up and commented out the whole section in d4dd55f. Considerations:
width=3cm, height=1null
mean "3 cm tall, width to fill" or "3 cm tall, aspect=1"? Is it possible/reasonable to parse that intention from grob dimensions andrespect
alone?respect
is set? Currently leaning no (if the other dimension has no nulls, it doesn't mean anything to respect them), but my understanding ofrespect
is weak.height=3cm+1null
? gtable and GridExtra both seem buggy on this (looks like they ignore the null part?), so probably not worth it.I don't think this scenario ever happens in ggplot output, but probably needs fixing before I can claim full GridExtra/cowplot support.
The text was updated successfully, but these errors were encountered: