-
Notifications
You must be signed in to change notification settings - Fork 271
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
BUG: fix figure layout in case the long axis is vertical #3633
Conversation
I modified the testing framework to make image comparison possible even when shapes diverge |
d491380
to
af7093c
Compare
Adding this to the 4.0.2 meta issue as a candidate for the bug fix release, but it's not 100% clear that it should be considered a bug fix so I'd like this to be discussed in the review. |
Got a handful of expected failures, exclusively for images that are targeted by the patch, so I'm opening for review. |
I'm not convinced this plays correctly with user-specified aspect. Switching to draft for now |
e640486
to
a837f8c
Compare
Fixed the issue with user-defined aspect, I believe the result is now what users would expect: the size of the long axis stays consistent import yt
ds = yt.load_sample("KelvinHelmholtz")
slc = yt.SlicePlot(ds, "z", "density")
slc.save("/tmp/rect_1.png")
slc = yt.SlicePlot(ds, "z", "density", aspect=0.5)
slc.save("/tmp/rect_2.png")
slc = yt.SlicePlot(ds, "z", "density", aspect=0.2)
slc.save("/tmp/rect_3.png")
slc = yt.SlicePlot(ds, "z", "density", aspect=1.5)
slc.save("/tmp/rect_4.png") |
a837f8c
to
6884368
Compare
I think I got this to a stable state. Now it seems rather obvious that the code could be simplified/clarified, so I'm keeping the draft status, and I'll make a final push on this when I have time to focus on it again. |
I realized that my modified testing framework produces nice reports but will upload polluted artifacts that are not suited to update the answer store. |
I'm going to try to validate this by updating the answer store early. I'll do this in the least disruptive way possible by pushing a branch directly to the mother repo and check it out here so I don't need to iterate with reviewers to see wether my modified framework works as intended. |
It's alive ! now let's try to simplify the logic |
I think more and more that this should be considered a bug fix since I'm fulfilling the original intent of this code. |
@Xarthisius, if you get a chance, could you review the changes I did to the testing framework here please ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So after a lot of thought, I don't think this is quite the right approach. Consider the final two images you plotted:
slc = yt.SlicePlot(ds, "z", "density", aspect=0.2)
slc.save("/tmp/rect_3.png")
slc = yt.SlicePlot(ds, "z", "density", aspect=1.5)
slc.save("/tmp/rect_4.png")
The standard definition of an aspect ratio is width / height. But those final two images break that definition: in the first, you're setting an aspect ratio < 1 and getting an image where width > height and in the second the opposite. I think we should keep the standard definition.
The base problem you're trying to address is that small aspect ratio plots end up too tall, right? So why not adjust the default figure width to a smaller value if aspect ratio < 1 so that the height ends up more reasonable?
So I hear what you're saying, unfortunately the Also note that the baseline example (not using the |
@chrishavlin do you have thoughts on the current state? |
Ya, I've looked at this a few times the past couple days and I don't feel great about it, but I guess this PR isn't really the place to address the confusing way we handle aspect ratios. I think my main issue is that |
ok then, thanks for approving. I'll update this with an actual companion PR to the answer store |
Here's the companion PR yt-project/answer-store#29 |
f8adb34
to
8b35482
Compare
… expected don't have the same shape (store and upload the raw results, not padded images)
8b35482
to
1d402c5
Compare
Update: I've validated the companion PR to the answer store by checking it in on this side, so I believe it's good to go now. |
1d402c5
to
86ecbfc
Compare
thanks @cphyc for merging the companion PR. I bumped everywhere needed and I now expect CI to turn green |
…axis is vertical
…3-on-yt-4.0.x Backport PR #3633 on branch yt-4.0.x (BUG: fix figure layout in case the long axis is vertical)
PR Summary
fix #3632
![zy](https://user-images.githubusercontent.com/14075922/139578862-fcfc3cb6-6b56-4ce3-b1a5-ce2c788790b7.png)
Running the script therein I get:
I expect this to fail CI because we surely have a couple images whose size is going to change, and unfortunately I don't think our testing infra is currently able to manage this properly (see #3602)