- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Transparency for Poly3DCollection plot in Matplotlib
To plot a transparent Poly3DCollection plot in Matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots
- Create a new figure or activate an existing figure.
- Add an '~.axes.Axes' to the figure as part of a subplot arrangement with projection=3d.
- Create x, y and z data points.
- Make a list of vertices.
- Convert x, y and z data points into a zipped list of tuples.
- Get a list of instance of Poly3d.
- Add a 3D collection object to the plot using add_collection3d() method.
- Turn off the axes.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = [0, 2, 1, 1] y = [0, 0, 1, 0] z = [0, 0, 0, 1] vertices = [[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]] tupleList = list(zip(x, y, z)) poly3d = [[tupleList[vertices[ix][iy]] for iy in range(len(vertices[0]))] for ix in range(len(vertices))] ax.scatter(x, y, z) ax.add_collection3d(Poly3DCollection(poly3d, facecolors='w', linewidths=1, alpha=0.5)) ax.add_collection3d(Line3DCollection(poly3d, colors='k', linewidths=2, linestyles='--')) plt.axis('off') plt.show()
Output
- Related Articles
- How to turn off transparency in Matplotlib's 3D Scatter plot?
- Adjusting Text background transparency in Matplotlib
- Setting Transparency Based on Pixel Values in Matplotlib
- How to adjust transparency (alpha) in Seaborn pairplot using Matplotlib?
- Matplotlib Plots Lose Transparency When Saving as .ps/.eps
- How to change the transparency/opaqueness of a Matplotlib Table?
- How to plot a smooth 2D color plot for z = f(x, y) in Matplotlib?
- Plot different colors for different categorical levels using matplotlib
- Python - Plot a Histogram for Pandas Dataframe with Matplotlib?
- Plot a Line Graph for Pandas Dataframe with Matplotlib?
- Plot scatter points using plot method in Matplotlib
- Plot animated text on the plot in Matplotlib
- How to add a colorbar for a hist2d plot in Matplotlib?
- How to create minor ticks for a polar plot in matplotlib?
- Contour hatching in Matplotlib plot

Advertisements