Skip to content

Instantly share code, notes, and snippets.

@rishi93
Last active November 6, 2018 08:42
Show Gist options
  • Select an option

  • Save rishi93/3b0fda6f8c9ae35a82c8e253b9bd358f to your computer and use it in GitHub Desktop.

Select an option

Save rishi93/3b0fda6f8c9ae35a82c8e253b9bd358f to your computer and use it in GitHub Desktop.
Simple 3D plot in Matplotlib
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
# Create the figure and the axes
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d', title = 'A 3D curve')
# Prepare the data points
z = np.linspace(-4*np.pi, 4*np.pi, 100)
x = np.sin(z)
y = np.cos(z)
# Plot the data points
ax.plot(x, y, z)
# Display the plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment