Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Matplotlib 2.x

You're reading from  Mastering Matplotlib 2.x

Product type Book
Published in Nov 2018
Publisher Packt
ISBN-13 9781789617696
Pages 214 pages
Edition 1st Edition
Languages
Author (1):
Benjamin Walter Keller Benjamin Walter Keller
Profile icon Benjamin Walter Keller

Plotting with 3D axes

We will begin by importing numpy, matplotlib, and pyplot, as shown here:

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib notebook
# Set up figure size and DPI for screen demo
plt.rcParams['figure.figsize'] = (6,4)
plt.rcParams['figure.dpi'] = 150

How to add 3D axes to a figure

We will use the Matplotlib inline magic in Jupyter Notebook to create our plotting setup. Begin by making a new figure and add some axes to this figure. Add a subplot, as shown in the following code, along with the projection= '3D' keyword argument:

# Make a Axes3D
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}