Book Image

Python Data Analysis

By : Ivan Idris
Book Image

Python Data Analysis

By: Ivan Idris

Overview of this book

Table of Contents (22 chapters)
Python Data Analysis
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Key Concepts
Online Resources
Index

Three-dimensional plots


Two-dimensional plots are the bread and butter of data visualization. However, if you want to show off, nothing beats a good three-dimensional plot. I was in charge of a software package that could draw contour plots and three-dimensional plots. The software could even draw plots that when viewed with special glasses would pop right in front of you.

The matplotlib API has the Axes3D class for three-dimensional plots. By demonstrating how this class works, we will also show how the object-oriented matplotlib API works. The matplotlib Figure class is a top-level container for chart elements:

  1. Create a Figure object as follows:

    fig = plt.figure()
  2. Create an Axes3D object from the Figure object:

    ax = Axes3D(fig)
  3. The years and CPU transistor counts will be our x and y axes. It is required to create coordinate matrices from the years and CPU transistor counts arrays. Create the coordinate matrices with the NumPy meshgrid() function:

    X, Y = np.meshgrid(X, Y)
  4. Plot the data with the...