- 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
Make 3D plot interactive in Jupyter Notebook (Python & Matplotlib)
In this article, we can take a program code to show how we can make a 3D plot interactive using Jupyter Notebook.
Steps
Create a new figure, or activate an existing figure.
Create fig and ax variables using subplots method, where default nrows and ncols are 1, projection=’3d”.
Get x, y and z using np.cos and np.sin function.
Plot the 3D wireframe, using x, y, z and color="red".
Set a title to the current axis.
To show the figure, use plt.show() method.
Example
import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') u, v = np.mgrid[0:2 * np.pi:30j, 0:np.pi:20j] x = np.cos(u) * np.sin(v) y = np.sin(u) * np.sin(v) z = np.cos(v) ax.plot_wireframe(x, y, z, color="red") ax.set_title("Sphere") plt.show()
Output
- Related Articles
- Hide Matplotlib descriptions in Jupyter notebook
- Displaying rotatable 3D plots in IPython or Jupyter Notebook
- How do I omit Matplotlib printed output in Python / Jupyter notebook?
- Using Tkinter in Jupyter Notebook
- How to display a Dataframe next to a Plot in Jupyter Notebook?
- How to change the figsize for matshow() in Jupyter notebook using Matplotlib?
- How to plot 3D graphs using Python Matplotlib?
- How to make a 3D scatter plot in Python?
- Plot Matplotlib 3D plot_surface with contour plot projection
- Plot 3D bars without axes in Matplotlib
- How to plot a 3D density map in Python with Matplotlib?
- Creating a 3D plot in Matplotlib from a 3D numpy array
- How to start tensorflow Docker jupyter notebook?
- How get the (x,y) position pointing with mouse in an interactive plot (Python Matplotlib)?
- How to embed an interactive Matplotlib plot on a webpage?

Advertisements