Created
April 11, 2017 05:38
-
-
Save Seanny123/903f72ef13f4e4d8acd7b57b4ccaa9f5 to your computer and use it in GitHub Desktop.
Fading updating 3D plot
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
import numpy as np | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import proj3d | |
def main(): | |
fig = plt.figure() | |
ax = fig.add_subplot(111, projection='3d') | |
ax.set_ylim(-100, 100) | |
ax.set_xlim(-10, 10) | |
ax.set_zlim(-100, 100) | |
plt.ion() | |
plt.show() | |
x = np.arange(-50, 51) | |
lines = [] | |
num_l = 4 | |
plot_cols = ["r", "g", "y", "b"] | |
for l_i in range(num_l): | |
lines.append( | |
ax.plot([], [], [], c=plot_cols[l_i])[0]) | |
for y in np.arange(1, 30, 3): | |
z = x**2 + y | |
for l_i, line in enumerate(lines): | |
line.set_data(x, 0) | |
line.set_3d_properties(z+l_i*10) | |
line.set_alpha((num_l-l_i)/num_l) | |
plt.draw() | |
plt.pause(0.001) | |
input("Press [enter] to continue.") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment