Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix bug "Setting an alpha value to a Poly3DCollection #10237"#10747
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
You can combine these two lines. I think it was just a typo.
Just to get this straight: Are there now two PRs
both trying to fix#10237 simultaneously? |
Cloing in lieu of the older PR. Thanks@ImportanceOfBeingErnest and@JZCJackson |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
In order to set alpha successfully. In Poly3DCollection's set_alpha, facecolors3d should equal to facecolors.
PR Checklist
Snippet of code:
In latest version these two cases can not show the transparency of the graph. In my feature branch it has been fixed.
Case 1 (Setting facecolor and alpha individually, facecolor first):
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import matplotlib.pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
x = [1, 0.9, 1, 0]
y = [0, 0.7, 0, 1]
z = [0, 0.8, 1, 0]
verts = [list(zip(x, y, z))]
alpha=0.4
fc = "C0"
pc = Poly3DCollection(verts, linewidths=1)
pc.set_facecolor(fc)
pc.set_alpha(alpha)
ax.add_collection3d(pc)
plt.show()
Case 2 (Setting facecolors and alpha at instantiation):
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import matplotlib.pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
x = [1, 0.9, 1, 0]
y = [0, 0.7, 0, 1]
z = [0, 0.8, 1, 0]
verts = [list(zip(x, y, z))]
alpha=0.4
fc = "C0"
pc = Poly3DCollection(verts, alpha = alpha, facecolors=fc,
linewidths=1)
ax.add_collection3d(pc)
plt.show()