Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to draw 3D surfaces by matplotlib

Shulou Source: shulou.com Published: 2022-06-01 18:37:45 10月01日 Update

Editor to share with you how to draw 3D surfaces in matplotlib, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

Train of thought introduction:

Next we will use matplotlib to draw the Sinc function:

1. First of all, determine the interval drawn, the range of independent variables x belongs to [- 8,8] and y belongs to [- 8,8]. Therefore, it is necessary to change the grid point coordinates {(xmemy)} of XBI y.

two。 Draw the 3D surface of function on the interval by matplotlib

3. Show it.

Show the 3D effect first:

Program list:

Import tensorflow as tfimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dx = tf.linspace (- 8.,8100) # set the coordinate interval of x y = tf.linspace (- 8.,8100) # set the coordinate interval of x, y = tf.meshgrid (x, y) # generate grid points And then split it and return z = tf.sqrt (x-rays 2 + y-rays 2) z = tf.sin (z) / z # sinc function to realize fig = plt.figure () ax = Axes3D (fig) # draw the sinc function 3D curve ax.contour3D (x.numpy (), y.numpy (), z.numpy (), 50) plt.show () these are all the contents of the article "how to draw 3D surfaces by matplotlib". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Functions surfaces coordinates articles grids content intervals generation not much most ideas effects curves more lists knowledge programs variables ranges industries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker macOS NVidia Shulou Tech Info Xiaomi