Skip to content

Instantly share code, notes, and snippets.

@parulnith
Created April 13, 2019 11:33
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 parulnith/a33cdb15b8888ba40e8f91aa40c0f61c to your computer and use it in GitHub Desktop.
Save parulnith/a33cdb15b8888ba40e8f91aa40c0f61c to your computer and use it in GitHub Desktop.
# library
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
# Get the data (csv file is hosted on the web)
url = 'https://python-graph-gallery.com/wp-content/uploads/volcano.csv'
data = pd.read_csv(url)
# Transform it to a long format
df=data.unstack().reset_index()
df.columns=["X","Y","Z"]
# And transform the old column name in something numeric
df['X']=pd.Categorical(df['X'])
df['X']=df['X'].cat.codes
# We are going to do 20 plots, for 20 different angles
for angle in range(70,210,2):
# Make the plot
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_trisurf(df['Y'], df['X'], df['Z'], cmap=plt.cm.viridis, linewidth=0.2)
ax.view_init(30,angle)
filename='Volcano/Volcano_step'+str(angle)+'.png'
plt.savefig(filename, dpi=96)
plt.gca()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment