-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Incorrect zorder of bar elements in a 3d histogram #25534
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
Comments
I just tested it with |
Can you make an example w/o astropy? |
@jklymak sure, I updated the MWE. |
For reference, the docs for bar3d: https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.bar3d.html And the zsort param comes from: See also: That said, I'm going to close as a duplicate of #13728, which is already open and essentially the same. |
@ksunden I see, thanks a lot for the quick feedback! Sorry, I wasn't aware of the other issues. Somehow I didn't manage to find them. If I understand correctly, this behaviour is because of a missing proper 3d engine, which unfortunately will not come any time soon? Btw, I "fixed" this by saving the figure as an svg file and then manually reordering the different elements. |
yeah, there may be a path to properly ordering at least the narrow case of bar charts (which have only orthogonal rectangles, so there might be something that can be done there) Essentially, the three (I'm pretty sure we only draw visible sides) polygons for each bar need to be drawn together and in a back to front as a unit. Currently the Poly3DCollection has no such grouping of polygons, so each side is determined what effective zorder (because the whole collection only has one actual zorder in relation to any other object) that bar has. and since the "average" "min" or "max" position of each of those polys is not consistent between bars which one should take precedence, adjacent bars are drawn between the sets. A general solution is not likely to be had in the near-medium term. |
That's a shame, but understandable. The general case is not an easy thing to fix. Thanks a lot for the explanations! |
Bug summary
I am trying to create a 3d histogram following the solution suggested here, which is based on [this matplotlib demo](Create 3D histogram of 2D data). In the finished plot however, the
zorder
of the bar sides are all messed up.Code for reproduction
Actual outcome
Expected outcome
A plot where the zorder is correct (although I have to admit, the result looks like a neat art piece).
Additional information
I would guess it has something to do with the
zsort
argument, but I actually didn't manage to find the documentation forbar3d
, only this post. I tried all three possibilities, but none of them worked. Isbar3d
depreciated?Operating system
Windows 10
Matplotlib Version
3.6.1
Matplotlib Backend
backend_interagg
Python version
3.9.7
Jupyter version
No response
Installation
conda
The text was updated successfully, but these errors were encountered: