{"id":304299,"date":"2024-05-20T19:19:20","date_gmt":"2024-05-20T11:19:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/304299.html"},"modified":"2024-05-20T19:19:30","modified_gmt":"2024-05-20T11:19:30","slug":"%e5%a6%82%e4%bd%95%e4%b8%80%e6%ac%a1%e6%80%a7%e6%8e%8c%e6%8f%a1%e6%89%80%e6%9c%89-python-%e7%94%bb%e5%9b%be%e5%9f%ba%e7%a1%80%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/304299.html","title":{"rendered":"\u5982\u4f55\u4e00\u6b21\u6027\u638c\u63e1\u6240\u6709 Python \u753b\u56fe\u57fa\u7840\u64cd\u4f5c"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26220537\/f85810c5-fca0-4282-bbbe-f1359bbba02b.webp\" alt=\"\u5982\u4f55\u4e00\u6b21\u6027\u638c\u63e1\u6240\u6709 Python \u753b\u56fe\u57fa\u7840\u64cd\u4f5c\" \/><\/p>\n<p><p>\u4e00\u6b21\u6027\u638c\u63e1\u6240\u6709Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\u7684\u5173\u952e\u5728\u4e8e\u7406\u89e3\u51e0\u4e2a\u6838\u5fc3\u6982\u5ff5\uff1a<strong>\u5b66\u4e60Python\u7684\u7ed8\u56fe\u5e93\u3001\u638c\u63e1\u57fa\u672c\u7684\u7ed8\u56fe\u51fd\u6570\u3001\u719f\u6089\u56fe\u5f62\u7f8e\u5316\u6280\u5de7<\/strong>\u3001<strong>\u4ee5\u53ca\u7ec3\u4e60\u56fe\u5f62\u5c55\u793a\u6570\u636e\u7684\u65b9\u6cd5<\/strong>\u3002\u9996\u5148\uff0cPython\u63d0\u4f9b\u4e86\u591a\u4e2a\u7ed8\u56fe\u5e93\uff0c\u5982matplotlib\u3001seaborn\u3001Plotly\u7b49\uff0c\u6bcf\u4e2a\u5e93\u90fd\u6709\u5176\u7279\u8272\u548c\u5e94\u7528\u573a\u666f\u3002\u5176\u4e2d\uff0c<strong>matplotlib\u662f\u6700\u4e3a\u57fa\u7840\u4e14\u4f7f\u7528\u6700\u5e7f\u6cdb\u7684\u7ed8\u56fe\u5e93<\/strong>\uff0c\u7406\u89e3\u4e86matplotlib\u7684\u57fa\u7840\u64cd\u4f5c\uff0c\u5bf9\u4e8e\u5b66\u4e60\u5176\u4ed6\u7ed8\u56fe\u5e93\u5c06\u4f1a\u975e\u5e38\u6709\u5e2e\u52a9\u3002matplotlib\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7ed8\u56fe\u63a5\u53e3\uff0c\u80fd\u591f\u5e2e\u52a9\u7528\u6237\u8f7b\u677e\u5b8c\u6210\u4ece\u7b80\u5355\u7684\u76f4\u7ebf\u56fe\u3001\u6563\u70b9\u56fe\u5230\u590d\u6742\u7684\u4e09\u7ef4\u56fe\u5f62\u7684\u7ed8\u5236\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e86\u89e3Python\u7ed8\u56fe\u5e93<\/h3>\n<\/p>\n<p><p>Python\u7684\u7ed8\u56fe\u80fd\u529b\u4e3b\u8981\u4f9d\u9760\u5916\u90e8\u5e93\u5b9e\u73b0\uff0c\u6700\u8457\u540d\u548c\u6700\u5f3a\u5927\u7684\u7ed8\u56fe\u5e93\u5305\u62ecmatplotlib\u3001seaborn\u4ee5\u53caPlotly\u3002\u6bcf\u4e2a\u5e93\u90fd\u6709\u5176\u72ec\u7279\u4e4b\u5904\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>matplotlib<\/strong>\uff1a\u662fPython\u6700\u8457\u540d\u7684\u7ed8\u56fe\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e00\u5957\u5b8c\u6574\u7684\u7ed8\u56fe\u7cfb\u7edf\uff0c\u5305\u62ec\u521b\u5efa\u9759\u6001\u3001\u52a8\u6001\u548c\u4ea4\u4e92\u5f0f\u56fe\u7684\u80fd\u529b\u3002\u5b83\u7684\u8bbe\u8ba1\u54f2\u5b66\u662f\u80fd\u591f\u505a\u7b80\u5355\u7684\u4e8b\u60c5\u5bb9\u6613\uff0c\u540c\u65f6\u4e5f\u80fd\u64cd\u4f5c\u590d\u6742\u7684\u4e8b\u60c5\u3002matplotlib\u975e\u5e38\u7075\u6d3b\uff0c\u51e0\u4e4e\u53ef\u4ee5\u7ed8\u5236\u4efb\u4f55\u7c7b\u578b\u7684\u56fe\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>seaborn<\/strong>\uff1a\u5efa\u7acb\u5728matplotlib\u4e4b\u4e0a\uff0c\u63d0\u4f9b\u66f4\u9ad8\u7ea7\u7684\u754c\u9762\uff0c\u66f4\u9002\u5408\u7edf\u8ba1\u7ed8\u56fe\u3002seaborn\u80fd\u591f\u4e0epandas\u6570\u636e\u7ed3\u6784\u65e0\u7f1d\u5de5\u4f5c\uff0c\u975e\u5e38\u9002\u5408\u6570\u636e\u63a2\u7d22\u65f6\u4f7f\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Plotly<\/strong>\uff1a\u652f\u6301\u521b\u5efa\u4ea4\u4e92\u5f0f\u56fe\u8868\u7684\u7ed8\u56fe\u5e93\uff0c\u7279\u522b\u9002\u5408web\u5e94\u7528\u7a0b\u5e8f\u3002Plotly\u53ef\u4ee5\u7ed8\u5236\u591a\u79cd\u4ea4\u4e92\u5f0f\u56fe\u8868\uff0c\u652f\u6301\u4e91\u5b58\u50a8\u548c\u5171\u4eab\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u638c\u63e1\u57fa\u672c\u7684\u7ed8\u56fe\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528matplotlib\u7ed8\u56fe\u65f6\uff0c\u7406\u89e3\u51e0\u4e2a\u57fa\u672c\u7684\u51fd\u6570\u662f\u975e\u5e38\u91cd\u8981\u7684\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>plt.figure()<\/strong>\uff1a\u521b\u5efa\u4e00\u4e2a\u56fe\u5f62\u5b9e\u4f8b\uff0c\u53ef\u4ee5\u89c6\u4e3a\u7ed8\u56fe\u7684\u753b\u5e03\u3002\u901a\u8fc7\u8bbe\u7f6efigure\u7684\u53c2\u6570\uff0c\u53ef\u4ee5\u8c03\u6574\u56fe\u5f62\u7684\u5927\u5c0f\u548c\u5206\u8fa8\u7387\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>plt.plot()<\/strong>\uff1a\u662f\u6700\u5e38\u7528\u7684\u51fd\u6570\u4e4b\u4e00\uff0c\u4e3b\u8981\u7528\u4e8e\u7ed8\u5236\u7ebf\u6027\u56fe\u8868\uff0c\u5982\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u901a\u8fc7\u4e0d\u540c\u7684\u53c2\u6570\u548c\u5c5e\u6027\uff0c\u53ef\u4ee5\u8c03\u6574\u7ebf\u6761\u7684\u6837\u5f0f\u3001\u989c\u8272\u548c\u6807\u8bb0\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>plt.scatter()<\/strong>\uff1a\u7528\u4e8e\u7ed8\u5236\u6563\u70b9\u56fe\uff0c\u975e\u5e38\u9002\u5408\u89c2\u5bdf\u4e24\u4e2a\u53d8\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u4e0eplot\u7c7b\u4f3c\uff0cscatter\u4e5f\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u53c2\u6570\u6765\u81ea\u5b9a\u4e49\u6563\u70b9\u7684\u6837\u5f0f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>plt.bar()<\/strong>\u3001<strong>plt.barh()<\/strong>\uff1a\u7528\u4e8e\u7ed8\u5236\u6761\u5f62\u56fe\uff0c\u5206\u522b\u8868\u793a\u5782\u76f4\u548c\u6c34\u5e73\u6761\u5f62\u56fe\u3002\u6761\u5f62\u56fe\u662f\u5c55\u793a\u5206\u7c7b\u6570\u636e\u7684\u5e38\u7528\u56fe\u8868\u7c7b\u578b\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u719f\u6089\u56fe\u5f62\u7f8e\u5316\u6280\u5de7<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u4f7f\u56fe\u5f62\u66f4\u52a0\u7f8e\u89c2\u548c\u6613\u4e8e\u7406\u89e3\uff0cmatplotlib\u63d0\u4f9b\u4e86\u591a\u79cd\u7f8e\u5316\u56fe\u5f62\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u8c03\u6574\u989c\u8272\u548c\u6837\u5f0f<\/strong>\uff1a\u901a\u8fc7\u8c03\u6574\u7ebf\u6761\u989c\u8272\u3001\u5bbd\u5ea6\u3001\u5f62\u72b6\u3001\u6dfb\u52a0\u7f51\u683c\u7ebf\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u56fe\u5f62\u770b\u8d77\u6765\u66f4\u7f8e\u89c2\u3001\u66f4\u4e13\u4e1a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0\u56fe\u4f8b\u548c\u6807\u9898<\/strong>\uff1a\u4e3a\u56fe\u5f62\u6dfb\u52a0\u5408\u9002\u7684\u6807\u9898\u548c\u56fe\u4f8b\uff0c\u53ef\u4ee5\u8ba9\u8bfb\u8005\u66f4\u5feb\u5730\u4e86\u89e3\u56fe\u5f62\u7684\u5185\u5bb9\u548c\u610f\u56fe\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u98ce\u683c\u6837\u5f0f<\/strong>\uff1amatplotlib\u63d0\u4f9b\u4e86\u591a\u79cd\u9884\u8bbe\u7684\u98ce\u683c\u6837\u5f0f\uff0c\u5982<code>plt.style.use(&#039;classic&#039;)<\/code>\uff0c\u53ef\u4ee5\u5feb\u901f\u6539\u53d8\u56fe\u5f62\u7684\u6574\u4f53\u98ce\u683c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u7ec3\u4e60\u56fe\u5f62\u5c55\u793a\u6570\u636e\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u638c\u63e1\u4e86\u7ed8\u56fe\u57fa\u7840\u548c\u7f8e\u5316\u6280\u5de7\u540e\uff0c\u6700\u540e\u4e00\u6b65\u662f\u901a\u8fc7\u5b9e\u8df5\u6765\u5de9\u56fa\u5b66\u4e60\u6210\u679c\u3002\u8fd9\u5305\u62ec\u9009\u53d6\u5408\u9002\u7684\u56fe\u8868\u6765\u5c55\u793a\u6570\u636e\u3001\u7406\u89e3\u6570\u636e\u7279\u70b9\u3001\u7ed8\u5236\u591a\u56fe\u4ee5\u53ca\u7ec4\u5408\u56fe\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u56fe\u8868\u7c7b\u578b<\/strong>\uff1a\u6839\u636e\u6240\u8981\u5c55\u793a\u6570\u636e\u7684\u7c7b\u578b\u548c\u76ee\u7684\u9009\u62e9\u6700\u5408\u9002\u7684\u56fe\u8868\u3002\u4f8b\u5982\uff0c\u8981\u5c55\u793a\u8d8b\u52bf\u53ef\u4f7f\u7528\u7ebf\u56fe\uff0c\u5173\u7cfb\u7528\u6563\u70b9\u56fe\uff0c\u5206\u5e03\u7528\u76f4\u65b9\u56fe\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7406\u89e3\u6570\u636e\u7684\u7279\u70b9\u548c\u9700\u6c42<\/strong>\uff1a\u5728\u7ed8\u56fe\u524d\uff0c\u6df1\u5165\u7406\u89e3\u6570\u636e\u7684\u7279\u70b9\u3001\u7ed3\u6784\u548c\u9700\u6c42\uff0c\u53ef\u4ee5\u5e2e\u52a9\u9009\u62e9\u66f4\u5408\u9002\u7684\u7ed8\u56fe\u65b9\u5f0f\u548c\u8c03\u6574\u5408\u9002\u7684\u56fe\u5f62\u53c2\u6570\uff0c\u4ee5\u66f4\u597d\u5730\u5c55\u73b0\u6570\u636e\u7684\u7279\u70b9\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u9075\u5faa\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u914d\u5408\u4e0d\u65ad\u7684\u7ec3\u4e60\u548c\u63a2\u7d22\uff0c\u4e00\u6b21\u6027\u638c\u63e1\u6240\u6709Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\u4e0d\u518d\u662f\u96be\u4e8b\u3002\u91cd\u8981\u7684\u662f\u4e0d\u65ad\u5b9e\u8df5\uff0c\u9010\u6e10\u79ef\u7d2f\u7ecf\u9a8c\uff0c\u5e76\u638c\u63e1\u5982\u4f55\u6839\u636e\u6570\u636e\u7279\u70b9\u548c\u5c55\u793a\u9700\u6c42\u9009\u62e9\u548c\u8c03\u6574\u7ed8\u56fe\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u6709\u54ea\u4e9b\u5fc5\u5907\u7684Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\uff1f<\/strong><br \/>\nPython\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a\u521b\u5efa\u753b\u5e03\u3001\u6dfb\u52a0\u56fe\u5f62\u548c\u6587\u672c\u3001\u8bbe\u7f6e\u56fe\u5f62\u5c5e\u6027\uff08\u989c\u8272\u3001\u7ebf\u578b\u7b49\uff09\u3001\u6dfb\u52a0\u56fe\u6807\u548c\u56fe\u4f8b\u3001\u4fdd\u5b58\u548c\u5c55\u793a\u56fe\u50cf\u7b49\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u5feb\u901f\u638c\u63e1Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\uff1f<\/strong><br \/>\n\u8981\u5feb\u901f\u638c\u63e1Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a\u9996\u5148\u4e86\u89e3\u76f8\u5173\u753b\u56fe\u5e93\uff08\u5982Matplotlib\u3001Seaborn\u7b49\uff09\u7684\u57fa\u672c\u77e5\u8bc6\u548cAPI\u6587\u6863\uff1b\u5176\u6b21\uff0c\u901a\u8fc7\u9605\u8bfb\u793a\u4f8b\u4ee3\u7801\u548c\u6559\u7a0b\u5b66\u4e60\u4e0d\u540c\u7c7b\u578b\u56fe\u5f62\u7684\u7ed8\u5236\u65b9\u6cd5\uff1b\u7136\u540e\uff0c\u5c1d\u8bd5\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5e94\u7528\u6240\u5b66\u7684\u753b\u56fe\u6280\u5de7\uff1b\u6700\u540e\uff0c\u4e0d\u65ad\u7ec3\u4e60\u548c\u5b9e\u8df5\uff0c\u79ef\u7d2f\u7ecf\u9a8c\u3002<\/p>\n<p><strong>3. \u6709\u4ec0\u4e48\u63a8\u8350\u7684\u5b66\u4e60\u8d44\u6e90\u6765\u638c\u63e1Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\uff1f<\/strong><br \/>\n\u63a8\u8350\u4ee5\u4e0b\u5b66\u4e60\u8d44\u6e90\u6765\u638c\u63e1Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\uff1a\u5728\u7ebf\u6559\u7a0b\u548c\u4e66\u7c4d\uff0c\u5982Matplotlib\u5b98\u65b9\u6587\u6863\u3001Seaborn\u7684\u5728\u7ebf\u6559\u7a0b\u7b49\uff1b\u76f8\u5173\u7684\u89c6\u9891\u6559\u7a0b\uff0c\u5982YouTube\u4e0a\u7684Python\u753b\u56fe\u6559\u7a0b\u7b49\uff1b\u53c2\u4e0e\u9879\u76ee\u6216\u5b9e\u8df5\u6848\u4f8b\uff0c\u4f8b\u5982\u5728\u6570\u636e\u5206\u6790\u6216<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9879\u76ee\u4e2d\u5e94\u7528\u753b\u56fe\u6280\u5de7\uff1b\u4e0e\u5176\u4ed6\u6709\u7ecf\u9a8c\u7684Python\u5f00\u53d1\u8005\u4ea4\u6d41\u548c\u5b66\u4e60\uff0c\u53ef\u4ee5\u901a\u8fc7\u6280\u672f\u8bba\u575b\u3001\u793e\u4ea4\u5a92\u4f53\u7fa4\u7ec4\u7b49\u65b9\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u6b21\u6027\u638c\u63e1\u6240\u6709Python\u753b\u56fe\u57fa\u7840\u64cd\u4f5c\u7684\u5173\u952e\u5728\u4e8e\u7406\u89e3\u51e0\u4e2a\u6838\u5fc3\u6982\u5ff5\uff1a\u5b66\u4e60Python\u7684\u7ed8\u56fe\u5e93\u3001\u638c\u63e1\u57fa\u672c\u7684\u7ed8\u56fe\u51fd\u6570 [&hellip;]","protected":false},"author":3,"featured_media":304309,"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\/304299"}],"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=304299"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/304299\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/304309"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=304299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=304299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=304299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}