3D Plots

3D Plots

This notebook demonstrates a 3D surface plot and a 3D scatter plot using the same data which was used to create a contour map.

import pandas as pd
import numpy as np

import matplotlib.pyplot as plt

%matplotlib notebook

px = pd.read_csv("px_2D.csv", header=None)

x = px.iloc[0, 1:]
y = px.iloc[1:, 0]
px_values = px.iloc[1:, 1:]
X, Y = np.meshgrid(x, y)

fig, ax = plt.subplots(subplot_kw={"projection": "3d"})

# Plot the surface.
surf = ax.plot_surface(X, Y, px_values, cmap="RdBu",
                       linewidth=0, antialiased=False)

fig.show()
X, Y = np.meshgrid(x, y)

fig, ax = plt.subplots(subplot_kw={"projection": "3d"})

# Plot the surface.
surf = ax.scatter(X, Y, px_values, cmap="RdBu",
                       linewidth=0, antialiased=False)

fig.show()