| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
Oh, I see now: the aspect ratio will be set for the current view. Makes perfect sense! There appears to be connection between setting the box aspect to (1, 1, 1) and the new dimensions being (delta, delta, delta). Hacking it might preserve the limits … If I understand set_box_aspect correctly, v_internals = np.array((self.xaxis.get_view_interval(),
self.yaxis.get_view_interval(),
self.zaxis.get_view_interval()))
deltas = np.ptp(v_intervals, axis=1)
self.set_box_aspect(deltas)
should do the trick. (Unable to test this right now, so I'll let somebody else decide which approach is better.) |
Sorry, something went wrong.
|
@tfpf I actually quite like the result with your idea there: v_intervals = np.vstack((self.xaxis.get_view_interval(),
self.yaxis.get_view_interval(),
self.zaxis.get_view_interval()))
deltas = np.ptp(v_intervals, axis=1)
self.set_box_aspect(deltas)
# One liner for an existing axes3d `ax`:
# ax.set_box_aspect(np.ptp(np.array([a.get_view_interval() for a in (ax.xaxis, ax.yaxis, ax.zaxis)]), axis=1))I had another idea for how this could look like too, similar to the original idea except it keeps the current (here the default 4:4:3) box aspect ratio: v_intervals = np.vstack((self.xaxis.get_view_interval(),
self.yaxis.get_view_interval(),
self.zaxis.get_view_interval()))
mean = np.mean(v_intervals, axis=1)
delta = np.max(np.ptp(v_intervals, axis=1))
deltas = delta * self._box_aspect / min(self._box_aspect)
self.set_xlim3d(mean[0] - deltas[0] / 2., mean[0] + deltas[0] / 2.)
self.set_ylim3d(mean[1] - deltas[1] / 2., mean[1] + deltas[1] / 2.)
self.set_zlim3d(mean[2] - deltas[2] / 2., mean[2] + deltas[2] / 2.)If I had to choose one I think I would choose the last, since the user can precede it with a set_box_aspect((1, 1, 1)) and get the same result as the first. But would welcome input on this. I don't believe matlab has prior art for 3D plots here that we can copy. |
Sorry, something went wrong.
|
So to summarize, here are the three options I see:
I would vote 3 since it encompasses 1 and keeps clear separation between the functions that change the box aspect and the data aspect. Will make the change to 3 unless there are any objections. Perhaps 2 could be set_box_aspect('tight') or something similar? I'm not too familiar with the 2D analogue for this. |
Sorry, something went wrong.
|
For the PR cleanliness check, I'm not sure how to squash the image commits while making sure @patquem keeps credit for the work in their initial commit. Edit: I'll just keep them as the author on the squashed commit. |
Sorry, something went wrong.
This is a nice idea. Could use the adjustable keyword argument—how about: if adjustable == 'datalim': change the limits, keeping the box aspect the same if adjustable == 'box': change the box aspect, keeping the limits the same which would make it more closely resemble the behaviour of 2D axes. I am not too familiar with this part of the codebase, though. Perhaps somebody else could also provide their suggestions. |
Sorry, something went wrong.
|
I think matching that adjustable keyword is a good idea for API consistency. It looks like a decent bit of effort to build that scaffolding which I don't really have time to do at the moment, so I would say that we keep this as-is and put that in a separate PR. In other words, just doing the adjustable == 'datalim' behavior right now. |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good. Changing those gallery examples was also a nice touch!
Sorry, something went wrong.
|
Nice discussion, which probably shows why it wasn't implemented earlier: there are lots of definitions of "equal" here... One thing that struck me, that of course doesn't have to be part of this, is that maybe one would also like to add something like "equalyxy", "equalxz" and "equalyz" to set two out of three axes equal? |
Sorry, something went wrong.
|
@oscargus good idea, wasn't too hard to add! |
Sorry, something went wrong.
Whats new for 3D plot equal aspect ratio
Code review updates
set_aspect('equal') now adopts current box aspect
Update test image
Update whats new
Update whats new
test image
Update docstrings
|
Updated to maximally fill the available space (it was shrunk before), and changed the what's new plotted cuboid to side lengths (1, 1, 5) to exaggerate what's happening: |
Sorry, something went wrong.
|
Huh, gallery updates must have gotten lost in a rebase, added back in |
Sorry, something went wrong.
|
As discussed in the dev call yesterday, this is now a blocker for #23449. |
Sorry, something went wrong.
|
🎉 I'm very excited this is going in! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
This replaces #23017. As requested in the thread I rebased and added the What's New entry. I think that @patquem will retain the credit for their work in the first commit, please let me know if I did this wrong.
Closes #22570
PR Checklist
Tests and Styling
Documentation