Python for Finance: Analyze Big Financial Data

(Elle) #1
shade Whether to shade the face colors

As with two-dimensional plots, the line style can be replaced by single points or, as in


what follows, single triangles. Figure 5-24 plots the same data as a 3D scatter plot, but


now also with a different viewing angle, using the view_init function to set it:


In  [ 36 ]: fig =   plt.figure(figsize=( 8 ,     5 ))
ax = fig.add_subplot( 111 , projection=‘3d’)
ax.view_init( 30 , 60 )

ax.scatter(strike,  ttm,    iv, zdir=‘z’,   s= 25 ,
c=‘b’, marker=‘^’)

ax.set_xlabel(‘strike’)
ax.set_ylabel(‘time-to-maturity’)
ax.set_zlabel(‘implied volatility’)

Figure 5-24. 3D scatter plot for (fake) implied volatilities
Free download pdf