Created
March 29, 2018 04:24
-
-
Save suicao/3dc9fa318bb8d8d19d4fa6288c236219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
from matplotlib.ticker import LinearLocator | |
import numpy as np | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
# Make data. | |
X = np.arange(1000, 4000, 3) | |
xlen = len(X) | |
Y = np.arange(1000, 4000, 3) | |
ylen = len(Y) | |
X, Y = np.meshgrid(X, Y) | |
Z = ((((X/((Y/3.5)+X))*300)*0.3)+(((((X*3.25)+10000)-(Y*3.25))/100)*0.7))-50 | |
Z[Z < 0] = 0 | |
Z2 = 90*np.exp((91/360000)*(X - Y)) + (140/9)*(np.log(X) - np.log(Y)) | |
Z2[Z2 < 0] = 0 | |
# Create an empty array of strings with the same shape as the meshgrid, and | |
# populate it with two colors in a checkerboard pattern. | |
colortuple = ('y', 'b') | |
colortuple2 = ('r', 'r') | |
colors = np.empty(X.shape, dtype=str) | |
colors2 = np.empty(X.shape, dtype=str) | |
for y in range(ylen): | |
for x in range(xlen): | |
colors[x, y] = colortuple[(x + y) % len(colortuple)] | |
colors2[x, y] = colortuple2[(x + y) % len(colortuple2)] | |
# Plot the surface with face colors taken from the array we made. | |
surf = ax.plot_surface(X, Y, Z, facecolors=colors, linewidth=0) | |
surf = ax.plot_surface(X, Y, Z2, facecolors=colors2, linewidth=0) | |
# Customize the z axis. | |
ax.set_zlim(0, 150) | |
ax.w_zaxis.set_major_locator(LinearLocator(6)) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment