Professional Documents
Culture Documents
Surface Plots- Jan 6th - LAB4 Jupyter Notebook
Surface Plots- Jan 6th - LAB4 Jupyter Notebook
SURFACE PLOTS
1 Date: 06/01/24 and LAB-4
1 AIM: In this lab, we shall explore the mpl_toolkits module and import the mplot3d
function and use meshgrid(), axes() and projection() to plot different surface
plots.
In [15]: 1 ax=Axes3D(figure())
2 x= arange(-3*pi, 3*pi, 0.1)
3 y= arange(-3*pi, 3*pi, 0.1)
4 xx,yy= meshgrid(x,y)
5 z= sin(xx)*sin(yy)
6 ax.plot_surface(xx, yy, z, cmap=cm.jet)
7 show()
C:\Users\liona\AppData\Local\Temp\ipykernel_36392\1212097329.py:1: MatplotlibDepreca
tionWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass t
he keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress th
is warning. The default value of auto_add_to_figure will change to False in mpl3.5 a
nd True values will no longer work in 3.6. This is consistent with other Axes class
es.
ax=Axes3D(figure())
In [22]: 1 ax=Axes3D(figure())
2 x= arange(-3*pi, 3*pi, 0.1)
3 y= arange(-3*pi, 3*pi, 0.1)
4 xx,yy= meshgrid(x,y)
5 z= xx+yy
6 ax.plot_surface(xx, yy, z, cmap=cm.Spectral)
7 show()
C:\Users\liona\AppData\Local\Temp\ipykernel_36392\1025354389.py:1: MatplotlibDepreca
tionWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass t
he keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress th
is warning. The default value of auto_add_to_figure will change to False in mpl3.5 a
nd True values will no longer work in 3.6. This is consistent with other Axes class
es.
ax=Axes3D(figure())
Vectors
In [24]: 1 ax= axes(projection= "3d")
2 x,y,z =meshgrid( arange(-0.8, 1, 0.2),
3 arange(-0.8, 1, 0.2),
4 arange(-0.8, 1, 0.8))
5 u= sin(pi*x)*cos(pi*y)*cos(pi*z) #vectorsof the form ui + vj + wz
6 v= cos(pi*x)*sin(pi*y)*cos(pi*z)
7 w=(sqrt(2.0/3.0)*cos(pi*x)*cos(pi*y)*sin(pi*z))
8 ax.quiver(x,y,z,u,v,w, length= 0.3) #x, y, z defines the arrow location
9 show()
𝑢 = 𝑥/𝑥 ∗ ∗2 + 𝑦 ∗ ∗2
localhost:8888/notebooks/Python SEM4/Surface Plots- Jan 6th.ipynb# 5/6
1/20/24, 12:25 PM Surface Plots- Jan 6th - Jupyter Notebook
1 Conclusion: Overall we have explored the mpl_toolkits module and imported the
mplot3d functions. Moreover we have also learnt to plot 3-D Surface plots using
axes(), meshgrid() and projection() fucntions.