TriSurface Plot in Python using Matplotlib (original) (raw)

from mpl_toolkits.mplot3d import Axes3D

import matplotlib.pyplot as plt

import numpy as np

r = np.linspace( 0.125 , 1.0 , 100 )

a = np.linspace( 0 , 2 * np.pi,

`` 100 ,

`` endpoint = False )

a = np.repeat(a[..., np.newaxis], 100 , axis = 1 )

x = np.append( 0 , (r * np.cos(a)))

y = np.append( 0 , (r * np.sin(a)))

z = (np.sin(x * * 4 ) + np.cos(y * * 4 ))

fig = plt.figure(figsize = ( 16 , 9 ))

ax = plt.axes(projection = '3d' )

my_cmap = plt.get_cmap( 'hot' )

trisurf = ax.plot_trisurf(x, y, z,

`` cmap = my_cmap,

`` linewidth = 0.2 ,

`` antialiased = True ,

`` edgecolor = 'grey' )

fig.colorbar(trisurf, ax = ax, shrink = 0.5 , aspect = 5 )

ax.set_title( 'Tri-Surface plot' )

ax.set_xlabel( 'X-axis' , fontweight = 'bold' )

ax.set_ylabel( 'Y-axis' , fontweight = 'bold' )

ax.set_zlabel( 'Z-axis' , fontweight = 'bold' )

plt.show()