- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
How to plot a 3D patch collection in matplotlib?
To plot a 3D patch collection 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.
- Get the current axes and set projection as 3d.
- Iterate ["x", "y", "z"] list, and set the circle patch using pathpatch_2d_to_3d() method to convert a PathPatch to a PathPatch3D object.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt from matplotlib.patches import Circle import mpl_toolkits.mplot3d.art3d as art3d plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.gca(projection='3d') for i in ["x", "y", "z"]: cir = Circle((0.5, 0.5), 0.2, color='red') ax.add_patch(cir) art3d.pathpatch_2d_to_3d(cir, z=0, zdir=i) plt.show()
Output
- Related Articles
- How to rotate the rectangle patch in a plot using Matplotlib?
- How to surface plot/3D plot from a dataframe (Matplotlib)?
- How to plot a 3D continuous line in Matplotlib?
- How to plot a point on 3D axes in Matplotlib?
- How to plot 3D graphs using Python Matplotlib?
- Creating a 3D plot in Matplotlib from a 3D numpy array
- How to plot a 3D density map in Python with Matplotlib?
- How to label a patch in matplotlib?
- How to display a 3D plot of a 3D array isosurface in matplotlib mplot3D or similar?
- Plot 3D bars without axes in Matplotlib
- Plot Matplotlib 3D plot_surface with contour plot projection
- How to plot scatter points in a 3D figure with a colorbar in Matplotlib?
- How to turn off transparency in Matplotlib's 3D Scatter plot?
- Setting the aspect ratio of a 3D plot in Matplotlib
- How to hide axes but keep axis-labels in 3D Plot with Matplotlib?

Advertisements