{"id":1120359,"date":"2025-01-08T18:55:33","date_gmt":"2025-01-08T10:55:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1120359.html"},"modified":"2025-01-08T18:55:36","modified_gmt":"2025-01-08T10:55:36","slug":"%e5%a6%82%e4%bd%95%e8%ae%a9python%e5%8f%af%e4%bb%a5%e7%94%bb3d%e5%9b%be","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1120359.html","title":{"rendered":"\u5982\u4f55\u8ba9python\u53ef\u4ee5\u753b3d\u56fe"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25083043\/244594e9-72aa-46d6-a39a-e733102a2566.webp\" alt=\"\u5982\u4f55\u8ba9python\u53ef\u4ee5\u753b3d\u56fe\" \/><\/p>\n<p><p> <strong>\u8981\u8ba9Python\u53ef\u4ee5\u753b3D\u56fe\uff0c\u53ef\u4ee5\u4f7f\u7528Matplotlib\u3001Mayavi\u548cPlotly\u3002<\/strong> <\/p>\n<\/p>\n<p><p><strong>Matplotlib<\/strong> \u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u7ed8\u56fe\u5e93\u4e4b\u4e00\uff0c\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u76842D\u548c3D\u7ed8\u56fe\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u5e38\u89c1\u7684\u7ed8\u56fe\u9700\u6c42\u3002<strong>Mayavi<\/strong> \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177\uff0c\u9002\u5408\u7528\u4e8e\u590d\u6742\u76843D\u56fe\u5f62\u548c\u52a8\u753b\u3002<strong>Plotly<\/strong> \u5219\u63d0\u4f9b\u4e86\u4ea4\u4e92\u5f0f\u76843D\u7ed8\u56fe\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u9700\u8981\u7528\u6237\u4ea4\u4e92\u7684\u573a\u666f\u3002\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e09\u79cd\u5de5\u5177\u6765\u7ed8\u52363D\u56fe\u5f62\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e00\u3001Matplotlib<\/h2>\n<\/p>\n<p><h3>1.1 \u5b89\u88c5\u548c\u57fa\u672c\u8bbe\u7f6e<\/h3>\n<\/p>\n<p><p>Matplotlib\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u7ed8\u56fe\u5e93\u4e4b\u4e00\uff0c\u8981\u4f7f\u7528\u5b83\u7ed8\u52363D\u56fe\u5f62\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Matplotlib\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7pip\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><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\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><\/code><\/pre>\n<\/p>\n<p><h3>1.2 \u57fa\u672c\u7ed8\u56fe<\/h3>\n<\/p>\n<p><p>Matplotlib\u63d0\u4f9b\u4e86\u7b80\u5355\u76843D\u7ed8\u56fe\u529f\u80fd\uff0c\u53ef\u4ee5\u7ed8\u5236\u6563\u70b9\u56fe\u3001\u66f2\u7ebf\u56fe\u548c\u8868\u9762\u56fe\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u57fa\u672c\u76843D\u6563\u70b9\u56fe\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<h2><strong>\u521b\u5efa\u4e00\u4e2a3D\u5750\u6807\u8f74<\/strong><\/h2>\n<p>fig = plt.figure()<\/p>\n<p>ax = fig.add_subplot(111, projection=&#39;3d&#39;)<\/p>\n<h2><strong>\u751f\u6210\u6570\u636e<\/strong><\/h2>\n<p>x = np.random.standard_normal(100)<\/p>\n<p>y = np.random.standard_normal(100)<\/p>\n<p>z = np.random.standard_normal(100)<\/p>\n<h2><strong>\u7ed8\u52363D\u6563\u70b9\u56fe<\/strong><\/h2>\n<p>ax.scatter(x, y, z)<\/p>\n<h2><strong>\u8bbe\u7f6e\u5750\u6807\u8f74\u6807\u7b7e<\/strong><\/h2>\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<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e00\u4e2a3D\u5750\u6807\u8f74\uff0c\u7136\u540e\u751f\u6210\u968f\u673a\u6570\u636e\u5e76\u7ed8\u52363D\u6563\u70b9\u56fe\u3002\u6700\u540e\uff0c\u8bbe\u7f6e\u5750\u6807\u8f74\u6807\u7b7e\u5e76\u663e\u793a\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><h3>1.3 \u9ad8\u7ea7\u7ed8\u56fe<\/h3>\n<\/p>\n<p><p>Matplotlib\u8fd8\u63d0\u4f9b\u4e86\u7ed8\u52363D\u66f2\u7ebf\u56fe\u548c\u8868\u9762\u56fe\u7684\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a3D\u8868\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<h2><strong>\u521b\u5efa\u4e00\u4e2a3D\u5750\u6807\u8f74<\/strong><\/h2>\n<p>fig = plt.figure()<\/p>\n<p>ax = fig.add_subplot(111, projection=&#39;3d&#39;)<\/p>\n<h2><strong>\u751f\u6210\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<h2><strong>\u7ed8\u52363D\u8868\u9762\u56fe<\/strong><\/h2>\n<p>ax.plot_surface(x, y, z, cmap=&#39;viridis&#39;)<\/p>\n<h2><strong>\u8bbe\u7f6e\u5750\u6807\u8f74\u6807\u7b7e<\/strong><\/h2>\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<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u751f\u6210\u4e86\u4e00\u4e2a\u7f51\u683c\u6570\u636e\uff0c\u5e76\u4f7f\u7528<code>np.sin<\/code>\u51fd\u6570\u8ba1\u7b97z\u503c\uff0c\u7136\u540e\u4f7f\u7528<code>ax.plot_surface<\/code>\u51fd\u6570\u7ed8\u5236\u8868\u9762\u56fe\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e8c\u3001Mayavi<\/h2>\n<\/p>\n<p><h3>2.1 \u5b89\u88c5\u548c\u57fa\u672c\u8bbe\u7f6e<\/h3>\n<\/p>\n<p><p>Mayavi\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177\uff0c\u9002\u7528\u4e8e\u590d\u6742\u76843D\u56fe\u5f62\u548c\u52a8\u753b\u3002\u9996\u5148\u9700\u8981\u5b89\u88c5Mayavi\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7pip\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><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from mayavi import mlab<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.2 \u57fa\u672c\u7ed8\u56fe<\/h3>\n<\/p>\n<p><p>Mayavi\u63d0\u4f9b\u4e86\u5f3a\u5927\u76843D\u7ed8\u56fe\u529f\u80fd\uff0c\u53ef\u4ee5\u7ed8\u5236\u590d\u6742\u76843D\u56fe\u5f62\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u57fa\u672c\u76843D\u6563\u70b9\u56fe\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\u6570\u636e<\/strong><\/h2>\n<p>x = np.random.standard_normal(100)<\/p>\n<p>y = np.random.standard_normal(100)<\/p>\n<p>z = np.random.standard_normal(100)<\/p>\n<h2><strong>\u7ed8\u52363D\u6563\u70b9\u56fe<\/strong><\/h2>\n<p>mlab.points3d(x, y, z, scale_factor=0.1)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>mlab.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u751f\u6210\u968f\u673a\u6570\u636e\uff0c\u7136\u540e\u4f7f\u7528<code>mlab.points3d<\/code>\u51fd\u6570\u7ed8\u52363D\u6563\u70b9\u56fe\uff0c\u6700\u540e\u663e\u793a\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><h3>2.3 \u9ad8\u7ea7\u7ed8\u56fe<\/h3>\n<\/p>\n<p><p>Mayavi\u8fd8\u63d0\u4f9b\u4e86\u7ed8\u5236\u590d\u67423D\u56fe\u5f62\u7684\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a3D\u8868\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\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<h2><strong>\u7ed8\u52363D\u8868\u9762\u56fe<\/strong><\/h2>\n<p>mlab.surf(x, y, z, colormap=&#39;viridis&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>mlab.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u751f\u6210\u4e86\u4e00\u4e2a\u7f51\u683c\u6570\u636e\uff0c\u5e76\u4f7f\u7528<code>np.sin<\/code>\u51fd\u6570\u8ba1\u7b97z\u503c\uff0c\u7136\u540e\u4f7f\u7528<code>mlab.surf<\/code>\u51fd\u6570\u7ed8\u5236\u8868\u9762\u56fe\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e09\u3001Plotly<\/h2>\n<\/p>\n<p><h3>3.1 \u5b89\u88c5\u548c\u57fa\u672c\u8bbe\u7f6e<\/h3>\n<\/p>\n<p><p>Plotly\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u56fe\u5f62\u5e93\uff0c\u9002\u7528\u4e8e\u9700\u8981\u7528\u6237\u4ea4\u4e92\u7684\u573a\u666f\u3002\u9996\u5148\u9700\u8981\u5b89\u88c5Plotly\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7pip\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><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5bfc\u5165\u5fc5\u8981\u7684\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import plotly.graph_objects as go<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3.2 \u57fa\u672c\u7ed8\u56fe<\/h3>\n<\/p>\n<p><p>Plotly\u63d0\u4f9b\u4e86\u5f3a\u5927\u76843D\u7ed8\u56fe\u529f\u80fd\uff0c\u53ef\u4ee5\u7ed8\u5236\u4ea4\u4e92\u5f0f3D\u56fe\u5f62\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u57fa\u672c\u76843D\u6563\u70b9\u56fe\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import plotly.graph_objects as go<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u751f\u6210\u6570\u636e<\/strong><\/h2>\n<p>x = np.random.standard_normal(100)<\/p>\n<p>y = np.random.standard_normal(100)<\/p>\n<p>z = np.random.standard_normal(100)<\/p>\n<h2><strong>\u521b\u5efa3D\u6563\u70b9\u56fe<\/strong><\/h2>\n<p>fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z, mode=&#39;markers&#39;)])<\/p>\n<h2><strong>\u8bbe\u7f6e\u5750\u6807\u8f74\u6807\u7b7e<\/strong><\/h2>\n<p>fig.update_layout(scene=dict(<\/p>\n<p>                    xaxis_title=&#39;X Label&#39;,<\/p>\n<p>                    yaxis_title=&#39;Y Label&#39;,<\/p>\n<p>                    zaxis_title=&#39;Z Label&#39;))<\/p>\n<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>fig.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u751f\u6210\u968f\u673a\u6570\u636e\uff0c\u7136\u540e\u4f7f\u7528<code>go.Scatter3d<\/code>\u51fd\u6570\u521b\u5efa3D\u6563\u70b9\u56fe\uff0c\u6700\u540e\u8bbe\u7f6e\u5750\u6807\u8f74\u6807\u7b7e\u5e76\u663e\u793a\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><h3>3.3 \u9ad8\u7ea7\u7ed8\u56fe<\/h3>\n<\/p>\n<p><p>Plotly\u8fd8\u63d0\u4f9b\u4e86\u7ed8\u5236\u590d\u67423D\u56fe\u5f62\u7684\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a3D\u8868\u9762\u56fe\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import plotly.graph_objects as go<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u751f\u6210\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<h2><strong>\u521b\u5efa3D\u8868\u9762\u56fe<\/strong><\/h2>\n<p>fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])<\/p>\n<h2><strong>\u8bbe\u7f6e\u5750\u6807\u8f74\u6807\u7b7e<\/strong><\/h2>\n<p>fig.update_layout(scene=dict(<\/p>\n<p>                    xaxis_title=&#39;X Label&#39;,<\/p>\n<p>                    yaxis_title=&#39;Y Label&#39;,<\/p>\n<p>                    zaxis_title=&#39;Z Label&#39;))<\/p>\n<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>fig.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u751f\u6210\u4e86\u4e00\u4e2a\u7f51\u683c\u6570\u636e\uff0c\u5e76\u4f7f\u7528<code>np.sin<\/code>\u51fd\u6570\u8ba1\u7b97z\u503c\uff0c\u7136\u540e\u4f7f\u7528<code>go.Surface<\/code>\u51fd\u6570\u7ed8\u5236\u8868\u9762\u56fe\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u56db\u3001\u5e94\u7528\u573a\u666f\u548c\u6027\u80fd\u4f18\u5316<\/h2>\n<\/p>\n<p><h3>4.1 \u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Matplotlib<\/strong>\uff1a\u9002\u5408\u7528\u4e8e\u5e38\u89c1\u7684\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u53ef\u89c6\u5316\uff0c\u7279\u522b\u662f\u9700\u8981\u4e0e\u5176\u4ed6Matplotlib\u56fe\u5f62\u7ed3\u5408\u4f7f\u7528\u65f6\u3002<\/li>\n<li><strong>Mayavi<\/strong>\uff1a\u9002\u5408\u7528\u4e8e\u590d\u6742\u7684\u79d1\u5b66\u6570\u636e\u53ef\u89c6\u5316\uff0c\u7279\u522b\u662f\u9700\u8981\u7ed8\u5236\u590d\u67423D\u56fe\u5f62\u548c\u52a8\u753b\u65f6\u3002<\/li>\n<li><strong>Plotly<\/strong>\uff1a\u9002\u5408\u7528\u4e8e\u9700\u8981\u7528\u6237\u4ea4\u4e92\u7684\u573a\u666f\uff0c\u7279\u522b\u662f\u9700\u8981\u5728\u7f51\u9875\u6216\u4eea\u8868\u76d8\u4e2d\u5d4c\u5165\u4ea4\u4e92\u5f0f\u56fe\u5f62\u65f6\u3002<\/li>\n<\/ul>\n<p><h3>4.2 \u6027\u80fd\u4f18\u5316<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\uff0c\u6027\u80fd\u4f18\u5316\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u8003\u8651\u56e0\u7d20\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6027\u80fd\u4f18\u5316\u6280\u5de7\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u6570\u636e\u91c7\u6837<\/strong>\uff1a\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u91c7\u6837\u51cf\u5c11\u6570\u636e\u91cf\uff0c\u4ece\u800c\u63d0\u9ad8\u7ed8\u56fe\u6027\u80fd\u3002<\/li>\n<li><strong>\u7b80\u5316\u56fe\u5f62<\/strong>\uff1a\u5728\u7ed8\u5236\u590d\u6742\u56fe\u5f62\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u7b80\u5316\u56fe\u5f62\uff08\u4f8b\u5982\u51cf\u5c11\u7f51\u683c\u5bc6\u5ea6\uff09\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<li><strong>\u786c\u4ef6\u52a0\u901f<\/strong>\uff1a\u4e00\u4e9b\u7ed8\u56fe\u5e93\uff08\u4f8b\u5982Plotly\uff09\u652f\u6301\u786c\u4ef6\u52a0\u901f\uff0c\u53ef\u4ee5\u5229\u7528GPU\u52a0\u901f\u7ed8\u56fe\u3002<\/li>\n<\/ul>\n<hr>\n<p><h2>\u4e94\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u8be6\u7ec6\u4e86\u89e3\u4e86\u5982\u4f55\u4f7f\u7528Matplotlib\u3001Mayavi\u548cPlotly\u8fd9\u4e09\u79cd\u5de5\u5177\u6765\u7ed8\u52363D\u56fe\u5f62\u3002<strong>Matplotlib\u9002\u7528\u4e8e\u5e38\u89c1\u7684\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u53ef\u89c6\u5316\uff0cMayavi\u9002\u7528\u4e8e\u590d\u6742\u7684\u79d1\u5b66\u6570\u636e\u53ef\u89c6\u5316\uff0cPlotly\u9002\u7528\u4e8e\u9700\u8981\u7528\u6237\u4ea4\u4e92\u7684\u573a\u666f\u3002<\/strong>\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u548c\u9700\u6c42\u3002\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u91c7\u6837\u3001\u7b80\u5316\u56fe\u5f62\u548c\u786c\u4ef6\u52a0\u901f\u7b49\u65b9\u5f0f\u8fdb\u884c\u6027\u80fd\u4f18\u5316\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u5728Python\u4e2d\u7ed8\u52363D\u56fe\u5f62\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b89\u88c53D\u7ed8\u56fe\u5e93\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u7ed8\u52363D\u56fe\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u76f8\u5e94\u7684\u7ed8\u56fe\u5e93\u3002\u6700\u5e38\u7528\u7684\u5e93\u662fMatplotlib\u548cMayavi\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7pip\u547d\u4ee4\u8f7b\u677e\u5b89\u88c5\u8fd9\u4e9b\u5e93\uff0c\u4f8b\u5982\uff0c\u4f7f\u7528<code>pip install matplotlib<\/code>\u6765\u5b89\u88c5Matplotlib\uff0c\u6216\u4f7f\u7528<code>pip install mayavi<\/code>\u6765\u5b89\u88c5Mayavi\u3002\u5b89\u88c5\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5bfc\u5165\u5e93\u6765\u5f00\u59cb\u4f7f\u7528\uff0c\u4f8b\u5982<code>import matplotlib.pyplot as plt<\/code>\u3002<\/p>\n<p><strong>Python\u7ed8\u52363D\u56fe\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u7ed8\u52363D\u56fe\u5f62\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u3002\u4f7f\u7528Matplotlib\u65f6\uff0c\u53ef\u4ee5\u5229\u7528<code>Axes3D<\/code>\u6765\u521b\u5efa3D\u5750\u6807\u8f74\u5e76\u7ed8\u5236\u6563\u70b9\u56fe\u3001\u66f2\u7ebf\u56fe\u6216\u8868\u9762\u56fe\u3002Mayavi\u5219\u9002\u5408\u5904\u7406\u66f4\u590d\u6742\u76843D\u53ef\u89c6\u5316\u4efb\u52a1\uff0c\u652f\u6301\u591a\u79cd3D\u56fe\u5f62\u548c\u4ea4\u4e92\u529f\u80fd\u3002\u6b64\u5916\uff0cPlotly\u4e5f\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u9009\u62e9\uff0c\u5b83\u5141\u8bb8\u60a8\u521b\u5efa\u52a8\u6001\u548c\u53ef\u4ea4\u4e92\u76843D\u56fe\u5f62\u3002<\/p>\n<p><strong>\u5982\u4f55\u57283D\u56fe\u4e2d\u6dfb\u52a0\u6807\u7b7e\u548c\u56fe\u4f8b\uff1f<\/strong><br \/>\u57283D\u56fe\u4e2d\u6dfb\u52a0\u6807\u7b7e\u548c\u56fe\u4f8b\u53ef\u4ee5\u4f7f\u56fe\u5f62\u66f4\u6613\u4e8e\u7406\u89e3\u3002\u4f7f\u7528Matplotlib\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>set_xlabel()<\/code>\u3001<code>set_ylabel()<\/code>\u548c<code>set_zlabel()<\/code>\u65b9\u6cd5\u4e3a3D\u5750\u6807\u8f74\u6dfb\u52a0\u6807\u7b7e\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>plt.legend()<\/code>\u53ef\u4ee5\u5728\u56fe\u4e2d\u6dfb\u52a0\u56fe\u4f8b\uff0c\u4ee5\u4fbf\u4e8e\u533a\u5206\u4e0d\u540c\u7684\u6570\u636e\u7cfb\u5217\u3002\u5728Mayavi\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>mlab.text3d()<\/code>\u57283D\u7a7a\u95f4\u4e2d\u6dfb\u52a0\u6587\u672c\u6807\u6ce8\uff0c\u589e\u5f3a\u56fe\u5f62\u7684\u53ef\u8bfb\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u8ba9Python\u53ef\u4ee5\u753b3D\u56fe\uff0c\u53ef\u4ee5\u4f7f\u7528Matplotlib\u3001Mayavi\u548cPlotly\u3002 Matplotlib [&hellip;]","protected":false},"author":3,"featured_media":1120362,"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\/1120359"}],"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=1120359"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1120359\/revisions"}],"predecessor-version":[{"id":1120365,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1120359\/revisions\/1120365"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1120362"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1120359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1120359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1120359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}