{"id":1089849,"date":"2025-01-08T13:57:10","date_gmt":"2025-01-08T05:57:10","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1089849.html"},"modified":"2025-01-08T13:57:12","modified_gmt":"2025-01-08T05:57:12","slug":"python%e5%a6%82%e4%bd%95%e7%bb%98%e5%88%b6%e4%b8%89%e7%bb%b4%e5%9b%be%e5%83%8f-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1089849.html","title":{"rendered":"python\u5982\u4f55\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24202557\/0a025293-0e6f-4a13-8acf-15d2a684d77d.webp\" alt=\"python\u5982\u4f55\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\" \/><\/p>\n<p><p> <strong>Python\u5982\u4f55\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf<\/strong>\uff1a<strong>\u4f7f\u7528Matplotlib\u5e93\u3001\u4f7f\u7528Mayavi\u5e93\u3001\u4f7f\u7528Plotly\u5e93\u3001\u4f7f\u7528Vispy\u5e93<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Matplotlib\u5e93\u6765\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528Matplotlib\u5e93<\/h3>\n<\/p>\n<p><p>Matplotlib\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u7ed8\u56fe\u5e93\u4e4b\u4e00\uff0c\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\u6765\u521b\u5efa\u5404\u79cd\u56fe\u8868\u548c\u56fe\u50cf\uff0c\u5305\u62ec\u4e09\u7ef4\u56fe\u50cf\u3002Matplotlib\u7684<code>mpl_toolkits.mplot3d<\/code>\u6a21\u5757\u5141\u8bb8\u6211\u4eec\u8f7b\u677e\u5730\u521b\u5efa\u548c\u5b9a\u5236\u4e09\u7ef4\u56fe\u50cf\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Matplotlib<\/h4>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Matplotlib\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u4e09\u7ef4\u5750\u6807\u8f74<\/h4>\n<\/p>\n<p><p>\u5728Matplotlib\u4e2d\uff0c\u4e09\u7ef4\u56fe\u50cf\u9700\u8981\u4e00\u4e2a\u4e09\u7ef4\u5750\u6807\u8f74\uff0c\u4f7f\u7528<code>Axes3D<\/code>\u7c7b\u6765\u521b\u5efa\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>from mpl_toolkits.mplot3d import Axes3D<\/p>\n<p>fig = plt.figure()<\/p>\n<p>ax = fig.add_subplot(111, projection=&#39;3d&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe<\/h4>\n<\/p>\n<p><p>\u4e09\u7ef4\u6563\u70b9\u56fe\u662f\u6700\u5e38\u89c1\u7684\u4e09\u7ef4\u56fe\u50cf\u4e4b\u4e00\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>from mpl_toolkits.mplot3d import Axes3D<\/p>\n<p>import numpy as np<\/p>\n<p>fig = plt.figure()<\/p>\n<p>ax = fig.add_subplot(111, projection=&#39;3d&#39;)<\/p>\n<h2><strong>\u751f\u6210\u968f\u673a\u6570\u636e<\/strong><\/h2>\n<p>x = np.random.rand(100)<\/p>\n<p>y = np.random.rand(100)<\/p>\n<p>z = np.random.rand(100)<\/p>\n<p>ax.scatter(x, y, z)<\/p>\n<p>ax.set_xlabel(&#39;X Label&#39;)<\/p>\n<p>ax.set_ylabel(&#39;Y Label&#39;)<\/p>\n<p>ax.set_zlabel(&#39;Z Label&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>scatter<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\uff0c\u5e76\u4e14\u4e3a\u6bcf\u4e2a\u8f74\u8bbe\u7f6e\u4e86\u6807\u7b7e\u3002<\/p>\n<\/p>\n<p><h4>4. \u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe<\/h4>\n<\/p>\n<p><p>\u4e09\u7ef4\u66f2\u9762\u56fe\u7528\u4e8e\u8868\u793a\u4e09\u7ef4\u7a7a\u95f4\u4e2d\u7684\u66f2\u9762\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>from mpl_toolkits.mplot3d import Axes3D<\/p>\n<p>import numpy as np<\/p>\n<p>fig = plt.figure()<\/p>\n<p>ax = fig.add_subplot(111, projection=&#39;3d&#39;)<\/p>\n<h2><strong>\u751f\u6210\u7f51\u683c\u6570\u636e<\/strong><\/h2>\n<p>x = np.linspace(-5, 5, 100)<\/p>\n<p>y = np.linspace(-5, 5, 100)<\/p>\n<p>x, y = np.meshgrid(x, y)<\/p>\n<p>z = np.sin(np.sqrt(x&lt;strong&gt;2 + y&lt;\/strong&gt;2))<\/p>\n<p>ax.plot_surface(x, y, z, cmap=&#39;viridis&#39;)<\/p>\n<p>ax.set_xlabel(&#39;X Label&#39;)<\/p>\n<p>ax.set_ylabel(&#39;Y Label&#39;)<\/p>\n<p>ax.set_zlabel(&#39;Z Label&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>plot_surface<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\uff0c\u5e76\u4f7f\u7528<code>cmap<\/code>\u53c2\u6570\u8bbe\u7f6e\u989c\u8272\u6620\u5c04\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Mayavi\u5e93<\/h3>\n<\/p>\n<p><p>Mayavi\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u4e09\u7ef4\u6570\u636e\u53ef\u89c6\u5316\u5e93\uff0c\u7279\u522b\u9002\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u548c\u5de5\u7a0b\u5e94\u7528\u3002Mayavi\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u4e09\u7ef4\u7ed8\u56fe\u529f\u80fd\uff0c\u4e14\u6613\u4e8e\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Mayavi<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Mayavi\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5Mayavi\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install mayavi<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Mayavi\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from mayavi import mlab<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u751f\u6210\u968f\u673a\u6570\u636e<\/strong><\/h2>\n<p>x = np.random.rand(100)<\/p>\n<p>y = np.random.rand(100)<\/p>\n<p>z = np.random.rand(100)<\/p>\n<p>mlab.points3d(x, y, z, scale_factor=0.1)<\/p>\n<p>mlab.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>mlab.points3d<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\uff0c\u5e76\u8bbe\u7f6e\u4e86\u7f29\u653e\u56e0\u5b50\u3002<\/p>\n<\/p>\n<p><h4>3. \u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Mayavi\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from mayavi import mlab<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u751f\u6210\u7f51\u683c\u6570\u636e<\/strong><\/h2>\n<p>x, y = np.mgrid[-5:5:100j, -5:5:100j]<\/p>\n<p>z = np.sin(np.sqrt(x&lt;strong&gt;2 + y&lt;\/strong&gt;2))<\/p>\n<p>mlab.surf(x, y, z, colormap=&#39;viridis&#39;)<\/p>\n<p>mlab.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>mlab.surf<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\uff0c\u5e76\u4f7f\u7528<code>colormap<\/code>\u53c2\u6570\u8bbe\u7f6e\u989c\u8272\u6620\u5c04\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Plotly\u5e93<\/h3>\n<\/p>\n<p><p>Plotly\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7ed8\u56fe\u5e93\uff0c\u652f\u6301\u591a\u79cd\u56fe\u8868\u7c7b\u578b\uff0c\u5305\u62ec\u4e09\u7ef4\u56fe\u50cf\u3002Plotly\u7684\u4e09\u7ef4\u56fe\u50cf\u5177\u6709\u9ad8\u5ea6\u7684\u4ea4\u4e92\u6027\uff0c\u53ef\u4ee5\u901a\u8fc7\u9f20\u6807\u62d6\u52a8\u3001\u7f29\u653e\u548c\u65cb\u8f6c\u67e5\u770b\u4e0d\u540c\u7684\u89c6\u89d2\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Plotly<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Plotly\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5Plotly\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install plotly<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Plotly\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import plotly.graph_objs as go<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u751f\u6210\u968f\u673a\u6570\u636e<\/strong><\/h2>\n<p>x = np.random.rand(100)<\/p>\n<p>y = np.random.rand(100)<\/p>\n<p>z = np.random.rand(100)<\/p>\n<p>trace = go.Scatter3d(x=x, y=y, z=z, mode=&#39;markers&#39;)<\/p>\n<p>layout = go.Layout(scene=dict(xaxis_title=&#39;X&#39;, yaxis_title=&#39;Y&#39;, zaxis_title=&#39;Z&#39;))<\/p>\n<p>fig = go.Figure(data=[trace], layout=layout)<\/p>\n<p>fig.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>go.Scatter3d<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\uff0c\u5e76\u8bbe\u7f6e\u8f74\u6807\u7b7e\u3002<\/p>\n<\/p>\n<p><h4>3. \u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Plotly\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import plotly.graph_objs as go<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u751f\u6210\u7f51\u683c\u6570\u636e<\/strong><\/h2>\n<p>x = np.linspace(-5, 5, 100)<\/p>\n<p>y = np.linspace(-5, 5, 100)<\/p>\n<p>x, y = np.meshgrid(x, y)<\/p>\n<p>z = np.sin(np.sqrt(x&lt;strong&gt;2 + y&lt;\/strong&gt;2))<\/p>\n<p>trace = go.Surface(z=z, x=x, y=y)<\/p>\n<p>layout = go.Layout(scene=dict(xaxis_title=&#39;X&#39;, yaxis_title=&#39;Y&#39;, zaxis_title=&#39;Z&#39;))<\/p>\n<p>fig = go.Figure(data=[trace], layout=layout)<\/p>\n<p>fig.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>go.Surface<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\uff0c\u5e76\u8bbe\u7f6e\u8f74\u6807\u7b7e\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528Vispy\u5e93<\/h3>\n<\/p>\n<p><p>Vispy\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684\u56fe\u5f62\u5e93\uff0c\u7279\u522b\u9002\u7528\u4e8e\u5904\u7406\u5927\u91cf\u6570\u636e\u548c\u590d\u6742\u7684\u4e09\u7ef4\u56fe\u5f62\u3002Vispy\u57fa\u4e8eOpenGL\uff0c\u63d0\u4f9b\u4e86\u5feb\u901f\u4e14\u9ad8\u6548\u7684\u7ed8\u56fe\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Vispy<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Vispy\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5Vispy\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install vispy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Vispy\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import vispy<\/p>\n<p>from vispy import scene<\/p>\n<p>import numpy as np<\/p>\n<p>canvas = scene.SceneCanvas(keys=&#39;interactive&#39;, show=True)<\/p>\n<p>view = canvas.central_widget.add_view()<\/p>\n<h2><strong>\u751f\u6210\u968f\u673a\u6570\u636e<\/strong><\/h2>\n<p>x = np.random.rand(100)<\/p>\n<p>y = np.random.rand(100)<\/p>\n<p>z = np.random.rand(100)<\/p>\n<p>pos = np.vstack([x, y, z]).T<\/p>\n<p>scatter = scene.visuals.Markers()<\/p>\n<p>scatter.set_data(pos, face_color=&#39;red&#39;, size=5)<\/p>\n<p>view.add(scatter)<\/p>\n<p>view.camera = &#39;turntable&#39;<\/p>\n<p>if __name__ == &#39;__m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__&#39;:<\/p>\n<p>    vispy.app.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>scene.visuals.Markers<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u89c6\u56fe\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>3. \u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Vispy\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import vispy<\/p>\n<p>from vispy import scene<\/p>\n<p>import numpy as np<\/p>\n<p>canvas = scene.SceneCanvas(keys=&#39;interactive&#39;, show=True)<\/p>\n<p>view = canvas.central_widget.add_view()<\/p>\n<h2><strong>\u751f\u6210\u7f51\u683c\u6570\u636e<\/strong><\/h2>\n<p>x = np.linspace(-5, 5, 100)<\/p>\n<p>y = np.linspace(-5, 5, 100)<\/p>\n<p>x, y = np.meshgrid(x, y)<\/p>\n<p>z = np.sin(np.sqrt(x&lt;strong&gt;2 + y&lt;\/strong&gt;2))<\/p>\n<p>vertices = np.c_[x.ravel(), y.ravel(), z.ravel()]<\/p>\n<p>faces = []<\/p>\n<p>for i in range(x.shape[0] - 1):<\/p>\n<p>    for j in range(y.shape[1] - 1):<\/p>\n<p>        faces.append([i * x.shape[1] + j, (i + 1) * x.shape[1] + j, i * x.shape[1] + (j + 1)])<\/p>\n<p>        faces.append([(i + 1) * x.shape[1] + j, (i + 1) * x.shape[1] + (j + 1), i * x.shape[1] + (j + 1)])<\/p>\n<p>mesh = scene.visuals.Mesh(vertices=vertices, faces=faces, color=&#39;blue&#39;, edge_color=&#39;black&#39;)<\/p>\n<p>view.add(mesh)<\/p>\n<p>view.camera = &#39;turntable&#39;<\/p>\n<p>if __name__ == &#39;__main__&#39;:<\/p>\n<p>    vispy.app.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>scene.visuals.Mesh<\/code>\u51fd\u6570\u7ed8\u5236\u4e09\u7ef4\u66f2\u9762\u56fe\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u89c6\u56fe\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<strong>\u4f7f\u7528Matplotlib\u5e93<\/strong>\u9002\u5408\u5feb\u901f\u521b\u5efa\u548c\u5b9a\u5236\u4e09\u7ef4\u56fe\u50cf\uff0c<strong>\u4f7f\u7528Mayavi\u5e93<\/strong>\u9002\u5408\u79d1\u5b66\u8ba1\u7b97\u548c\u5de5\u7a0b\u5e94\u7528\uff0c<strong>\u4f7f\u7528Plotly\u5e93<\/strong>\u9002\u5408\u521b\u5efa\u4ea4\u4e92\u5f0f\u4e09\u7ef4\u56fe\u50cf\uff0c<strong>\u4f7f\u7528Vispy\u5e93<\/strong>\u9002\u5408\u5904\u7406\u5927\u91cf\u6570\u636e\u548c\u590d\u6742\u4e09\u7ef4\u56fe\u5f62\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\uff0c\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u5b8c\u6210\u4e09\u7ef4\u56fe\u50cf\u7684\u7ed8\u5236\u4efb\u52a1\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u5e93\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\uff0c\u6700\u5e38\u7528\u7684\u6709Matplotlib\u3001Mayavi\u548cPlotly\u3002Matplotlib\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u63a5\u53e3\uff0c\u901a\u8fc7mpl_toolkits.mplot3d\u6a21\u5757\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u4e09\u7ef4\u56fe\u5f62\u3002Mayavi\u9002\u5408\u4e8e\u590d\u6742\u7684\u4e09\u7ef4\u53ef\u89c6\u5316\uff0c\u800cPlotly\u5219\u652f\u6301\u4ea4\u4e92\u5f0f\u4e09\u7ef4\u56fe\u5f62\uff0c\u80fd\u591f\u5728\u7f51\u9875\u4e0a\u663e\u793a\u3002\u5177\u4f53\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5\u76f8\u5173\u5e93\u3001\u521b\u5efa\u4e09\u7ef4\u5750\u6807\u8f74\u3001\u7ed8\u5236\u6570\u636e\u70b9\u6216\u66f2\u9762\u7b49\u3002<\/p>\n<p><strong>\u4f7f\u7528Matplotlib\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u8bbe\u7f6e\uff1f<\/strong><br \/>\u5728\u4f7f\u7528Matplotlib\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\u65f6\uff0c\u786e\u4fdd\u6b63\u786e\u5bfc\u5165mpl_toolkits.mplot3d\u6a21\u5757\u3002\u9700\u8981\u8bbe\u7f6e\u56fe\u5f62\u7684\u89c6\u89d2\u3001\u5750\u6807\u8f74\u7684\u6807\u7b7e\u4ee5\u53ca\u56fe\u4f8b\u7b49\u3002\u6b64\u5916\uff0c\u9009\u62e9\u5408\u9002\u7684\u989c\u8272\u548c\u6807\u8bb0\u6837\u5f0f\u80fd\u8ba9\u56fe\u5f62\u66f4\u52a0\u6613\u4e8e\u7406\u89e3\u3002\u8c03\u6574\u89c6\u89d2\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528view_init\u65b9\u6cd5\uff0c\u6765\u8bbe\u7f6e\u89c2\u4f17\u7684\u89c2\u5bdf\u89d2\u5ea6\u3002<\/p>\n<p><strong>Python\u4e2d\u7684\u4e09\u7ef4\u56fe\u50cf\u53ef\u4ee5\u4fdd\u5b58\u4e3a\u54ea\u4e9b\u683c\u5f0f\uff1f<\/strong><br \/>Python\u4e2d\u7ed8\u5236\u7684\u4e09\u7ef4\u56fe\u50cf\u53ef\u4ee5\u4fdd\u5b58\u4e3a\u591a\u79cd\u683c\u5f0f\uff0c\u5305\u62ecPNG\u3001JPEG\u3001SVG\u3001PDF\u7b49\u3002\u4f7f\u7528Matplotlib\uff0c\u53ef\u4ee5\u901a\u8fc7savefig\u51fd\u6570\u8f7b\u677e\u4fdd\u5b58\u56fe\u50cf\uff0c\u6307\u5b9a\u6587\u4ef6\u540d\u548c\u683c\u5f0f\u5373\u53ef\u3002\u6b64\u5916\uff0cPlotly\u8fd8\u652f\u6301\u5c06\u56fe\u5f62\u5bfc\u51fa\u4e3aHTML\u6587\u4ef6\uff0c\u4fbf\u4e8e\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u548c\u5206\u4eab\u3002\u9009\u62e9\u5408\u9002\u7684\u683c\u5f0f\uff0c\u80fd\u591f\u786e\u4fdd\u56fe\u50cf\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u7684\u517c\u5bb9\u6027\u548c\u6e05\u6670\u5ea6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5982\u4f55\u7ed8\u5236\u4e09\u7ef4\u56fe\u50cf\uff1a\u4f7f\u7528Matplotlib\u5e93\u3001\u4f7f\u7528Mayavi\u5e93\u3001\u4f7f\u7528Plotly\u5e93\u3001\u4f7f\u7528Visp [&hellip;]","protected":false},"author":3,"featured_media":1089857,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1089849"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1089849"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1089849\/revisions"}],"predecessor-version":[{"id":1089859,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1089849\/revisions\/1089859"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1089857"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1089849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1089849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1089849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}