Skip to content

Instantly share code, notes, and snippets.

@lidopypy
Created January 24, 2019 09:01
Show Gist options
  • Save lidopypy/5e6a8828f28145128831a062dac1207e to your computer and use it in GitHub Desktop.
Save lidopypy/5e6a8828f28145128831a062dac1207e to your computer and use it in GitHub Desktop.
'''
========================
3D surface (solid color)
========================
Demonstrates a very basic plot of a 3D surface using a solid color.
'''
# This import registers the 3D projection, but is otherwise unused.
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
a= [0,1000,200,2,0.5,0]
# Make data
for i,j in enumerate (a):
u = np.linspace(0, 2 * np.pi, 1000)
v = np.linspace(0, np.pi, 1000)
x = i*0.5 * np.outer(np.cos(u), np.sin(v))
y = i*0.5 * np.outer(np.sin(u), np.sin(v))
z = i*0.5 * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z, color='b',alpha=j*0.001)
# Plot the surface
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment