Skip to content

Instantly share code, notes, and snippets.

@zztalker
Created June 18, 2018 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zztalker/38aa737d65dbd49d1e70ac865dc7655f to your computer and use it in GitHub Desktop.
Save zztalker/38aa737d65dbd49d1e70ac865dc7655f to your computer and use it in GitHub Desktop.
3d_plot.py
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
X = np.arange(1, 9, 1)
print(X)
Y = np.arange(1, 9, 1)
print(Y)
X, Y = np.meshgrid(X, Y)
print(X)
print(Y)
Z = X*Y
print(Z)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.set_zlim(0, 64)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment