-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
'Poly3DCollection' object has no attribute '_facecolors2d' #4067
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
Ok, I have a "fix", in the sense that that attribute will be defined upon initialization. However, for your example, the facecolors returned is completely useless ([[0, 0, 1, 1]] -- all blue, which is default). I suspect that there is a deeper problem with ScalarMappables in general in that they don't set their facecolors until draw time? |
The solution is to probably force the evaluation of the norm + cmap in |
The bigger question I have is if regular PolyCollections that are On Sat, Feb 7, 2015 at 6:42 PM, Thomas A Caswell [email protected]
|
PR #4090 addresses this. Although, it still doesn't return any useful On Mon, Feb 9, 2015 at 3:47 PM, Thomas A Caswell [email protected]
|
I believe I'm still running into this issue today. Below is the error message I receive when attempting to convert hb_made (a hexbin PolyCollection) into a Poly3DCollection. Are there any other ways to convert 2D PolyCollections into 3D PolyCollections?
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 2201, in add_collection3d |
I don't know if this is the appropriate place to post this, but here is a temporary fix for anyone who is waiting on the permanent fix. I encounter this same error when trying to add a legend to my 3D surface plot.
While a permanent fix is find, I found that a simple temporary fix is to explicitly set the
|
I also could not get the legend to show in my 3d plot of planes with the error:"AttributeError: 'Poly3DCollection' object has no attribute '_edgecolors2d'". Although the fix from @felipegb94 worked: |
I'm remilestoning this to keep it on the radar. |
I run into this today, but now even the workaround (#4067 (comment)) is not working any more. |
I ran into this today, with version 3.3.1.post1012+g5584ba764, the workaround did the trick. |
I ran in to this as well, and the fix works in version 3.3.1 but not in 3.3.3 |
@Bootje2000 Apparently some attributes have been renamed or moved around (prima facie). Try this slight modification to @felipegb94's workaround:
Note the lack of "s" on the RHS. This works in |
None of the workarounds work in matplotlib 3.5.1 Hint: if there are multiple surfaces on the same axes, the workaround must be applied to each surface individually. |
@nina-wwc I just checked the minimal working example in this thread using |
The problem still is that we update some state during the draw process. Internally we do the updating and the access in just the right order so that in most cases we do not notice that we also add the attributes on the fly. The best workaround for the current case (assuming 3.5): import numpy as np
import matplotlib.tri as mtri
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
y,x = np.ogrid[1:10:100j, 1:10:100j]
z2 = np.cos(x)**3 - np.sin(y)**2
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
r = ax.plot_surface(x,y,z2, cmap='hot')
fig.draw_without_rendering() # <--- This is the key line
r.get_facecolors() However, I still think the best solution is #4067 (comment) which will require looking in Labeling this as a good first issue because it clearly has affected a lot of people for a long time, there is a very clear reproduction example (that will make a perfect test), and there are no API design choices to be made, but medium difficulty because it will require understanding some slightly tricking inheritance and how our 3D artists draw them selves. |
The following minimal example demonstrates the issue:
It fails on the last line with the following traceback:
Tested with mpl versions 1.3.1 and 1.4.2.
Sent here by Benjamin, from the mpl users mailing list (mail with the same title). Sorry for dumping this without more assistance, I'm not yet at a python level where I can help in debugging, I think (well, it seems daunting).
The text was updated successfully, but these errors were encountered: