Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Matplotlib for Python Developers

You're reading from   Matplotlib for Python Developers Effective techniques for data visualization with Python

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788625173
Length 300 pages
Edition 2nd Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Aldrin Yim Aldrin Yim
Author Profile Icon Aldrin Yim
Aldrin Yim
Claire Chung Claire Chung
Author Profile Icon Claire Chung
Claire Chung
Allen Yu Allen Yu
Author Profile Icon Allen Yu
Allen Yu
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Title Page
Dedication
Packt Upsell
Contributors
Preface
1. Introduction to Matplotlib FREE CHAPTER 2. Getting Started with Matplotlib 3. Decorating Graphs with Plot Styles and Types 4. Advanced Matplotlib 5. Embedding Matplotlib in GTK+3 6. Embedding Matplotlib in Qt 5 7. Embedding Matplotlib in wxWidgets Using wxPython 8. Integrating Matplotlib with Web Applications 9. Matplotlib in the Real World 10. Integrating Data Visualization into the Workflow Index

3D plots with Axes3D


We have so far discussed plotting in two dimensions. In fact, there are numerous occasions where we may need 3D data visualizations. Examples include illustrating more complex mathematical functions, terrain features, fluid dynamics in physics, as well as just showing one more facet of our data.

In Matplotlib, it can done by Axes3D in the mplot3d library within mpl_toolkits.

We just need to specify projection='3d' when defining an axes object after importing the library. Next, we just have to define the axes with x, y, and z coordinates. Supported plot types include scatter plot, line plot, bar plot, contour plots, wireframe plots, and surface plots with or without triangulation.

The following is an example of drawing a 3D surface plot:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

x = np.linspace(-2, 2, 60)
y = np.linspace(-2, 2, 60)
x, y = np.meshgrid(x, y)
r ...
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 £13.99/month. Cancel anytime
Visually different images