{"id":119819,"date":"2026-10-30T14:24:49","date_gmt":"2026-10-30T06:24:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/119819.html"},"modified":"2026-10-30T14:24:49","modified_gmt":"2026-10-30T06:24:49","slug":"%e3%80%90python%e3%80%91%e5%9f%ba%e7%a1%80%e8%af%ad%e6%b3%95%e5%85%a5%e9%97%a8%ef%bc%88%e4%b8%89%e5%8d%81%e4%ba%94%ef%bc%89-%e6%95%b0%e6%8d%ae%e5%8f%af%e8%a7%86%e5%8c%96%ef%bc%9a","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/119819.html","title":{"rendered":"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe"},"content":{"rendered":"<p>\u524d\u8a00&#xff1a;\u4e0a\u7bc7\u6211\u4eec\u5b66\u4f1a\u4e86\u7528 pandas \u5904\u7406\u8868\u683c\u6570\u636e&#xff0c;\u4f46\u8868\u683c\u91cc\u5168\u662f\u6570\u5b57&#xff0c;\u4e0d\u591f\u76f4\u89c2\u3002\u4fd7\u8bdd\u8bf4&#034;\u4e00\u56fe\u80dc\u5343\u8a00&#034;&#xff0c;\u6570\u636e\u53ef\u89c6\u5316\u80fd\u628a\u67af\u71e5\u7684\u6570\u5b57\u53d8\u6210\u76f4\u89c2\u7684\u56fe\u8868&#xff0c;\u8ba9\u4eba\u4e00\u773c\u770b\u51fa\u8d8b\u52bf\u3001\u5206\u5e03\u548c\u5f02\u5e38\u3002\u672c\u7bc7\u5e26\u4f60\u638c\u63e1 Python \u6700\u7ecf\u5178\u7684\u7ed8\u56fe\u5e93\u2014\u2014matplotlib\u3002<\/p>\n<hr \/>\n<h3 id=\"\u4e00\u4e3a\u4ec0\u4e48\u8981\u753b\u56fe\">\u4e00\u3001\u4e3a\u4ec0\u4e48\u8981\u753b\u56fe<\/h3>\n<p>\u4eba\u7c7b\u5927\u8111\u5bf9\u56fe\u5f62\u7684\u611f\u77e5\u8fdc\u5feb\u4e8e\u5bf9\u6570\u5b57\u7684\u611f\u77e5\u3002\u8003\u8651\u8fd9\u4e24\u7ec4\u6570\u636e&#xff1a;<\/p>\n<p>A: [12, 15, 18, 22, 25, 30, 35, 40, 38, 42]<br \/>\nB: [42, 38, 40, 35, 30, 25, 22, 18, 15, 12]<\/p>\n<p>\u5149\u770b\u6570\u5b57&#xff0c;\u4f60\u80fd\u7acb\u523b\u8bf4\u51fa\u5b83\u4eec\u7684\u533a\u522b\u5417&#xff1f;\u4f46\u753b\u6210\u6298\u7ebf\u56fe&#xff0c;\u4e00\u4e2a\u4e0a\u5347\u4e00\u4e2a\u4e0b\u964d&#xff0c;\u4e00\u76ee\u4e86\u7136\u3002<\/p>\n<p>\u6570\u636e\u53ef\u89c6\u5316\u7684\u4ef7\u503c&#xff1a;<\/p>\n<table>\n<tr>\u573a\u666f\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u63a2\u7d22\u6027\u5206\u6790<\/td>\n<td>\u53d1\u73b0\u89c4\u5f8b\u3001\u5f02\u5e38\u3001\u8d8b\u52bf<\/td>\n<\/tr>\n<tr>\n<td>\u6c47\u62a5\u5c55\u793a<\/td>\n<td>\u8ba9\u975e\u6280\u672f\u4eba\u5458\u770b\u61c2\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u51b3\u7b56\u652f\u6301<\/td>\n<td>\u7528\u6570\u636e\u9a71\u52a8\u51b3\u7b56<\/td>\n<\/tr>\n<tr>\n<td>\u76d1\u63a7\u9884\u8b66<\/td>\n<td>\u5b9e\u65f6\u56fe\u8868\u53d1\u73b0\u5f02\u5e38<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3 id=\"\u4e8cmatplotlib-\u7b80\u4ecb\">\u4e8c\u3001matplotlib \u7b80\u4ecb<\/h3>\n<p>matplotlib \u662f Python \u6700\u57fa\u7840\u3001\u6700\u5168\u9762\u7684\u7ed8\u56fe\u5e93&#xff0c;\u7531 John Hunter \u4e8e 2003 \u5e74\u5f00\u53d1\u3002\u51e0\u4e4e\u6240\u6709\u9ad8\u7ea7\u7ed8\u56fe\u5e93&#xff08;seaborn\u3001pandas \u7684 plot&#xff09;\u90fd\u57fa\u4e8e\u5b83\u3002<\/p>\n<p>\u6838\u5fc3\u67b6\u6784&#xff1a;<\/p>\n<p>Figure&#xff08;\u753b\u5e03&#xff09;<br \/>\n  \u2514\u2500\u2500 Axes&#xff08;\u5750\u6807\u7cfb\/\u5b50\u56fe&#xff09;<br \/>\n        \u2514\u2500\u2500 Artist&#xff08;\u56fe\u5f62\u5143\u7d20&#xff1a;\u7ebf\u3001\u70b9\u3001\u6587\u5b57\u7b49&#xff09;<\/p>\n<ul>\n<li>Figure&#xff1a;\u6574\u4e2a\u753b\u5e03&#xff0c;\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u5b50\u56fe\u3002<\/li>\n<li>Axes&#xff1a;\u4e00\u4e2a\u5750\u6807\u7cfb&#xff0c;\u6211\u4eec\u753b\u7684\u56fe\u5c31\u5728\u8fd9\u91cc&#xff08;\u6ce8\u610f\u4e0d\u662f&#034;\u8f74&#034;axis&#xff09;\u3002<\/li>\n<li>Artist&#xff1a;\u6240\u6709\u53ef\u89c1\u5143\u7d20&#xff0c;\u5982\u7ebf\u6761\u3001\u6807\u9898\u3001\u56fe\u4f8b\u3002<\/li>\n<\/ul>\n<p>pylab vs pyplot&#xff1a;<\/p>\n<ul>\n<li>pylab&#xff1a;\u628a matplotlib \u548c numpy \u7684\u547d\u540d\u7a7a\u95f4\u5408\u5e76&#xff0c;\u7c7b\u4f3c MATLAB&#xff0c;\u73b0\u5df2\u4e0d\u63a8\u8350\u3002<\/li>\n<li>pyplot&#xff1a;\u63d0\u4f9b\u7c7b\u4f3c MATLAB \u7684\u7b80\u6d01\u63a5\u53e3&#xff0c;\u6700\u5e38\u7528&#xff0c;import matplotlib.pyplot as plt\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"\u4e09\u5b89\u88c5\">\u4e09\u3001\u5b89\u88c5<\/h3>\n<p>pip install matplotlib<\/p>\n<p>\u9a8c\u8bc1&#xff1a;<\/p>\n<p>import matplotlib.pyplot as plt<br \/>\nimport matplotlib<br \/>\nprint(matplotlib.__version__)  # 3.7.2<\/p>\n<p>\u5728 Jupyter Notebook \u4e2d&#xff0c;\u52a0\u4e0a\u00a0%matplotlib inline\u00a0\u5373\u53ef\u5728\u7f51\u9875\u5185\u663e\u793a\u56fe\u8868\u3002\u5728\u811a\u672c\u4e2d\u7528\u00a0plt.show()\u00a0\u5f39\u51fa\u7a97\u53e3\u3002<\/p>\n<hr \/>\n<h3 id=\"\u56db\u6298\u7ebf\u56fe-plot\">\u56db\u3001\u6298\u7ebf\u56fe plot<\/h3>\n<h4 id=\"41-\u57fa\u672c\u6298\u7ebf\">4.1 \u57fa\u672c\u6298\u7ebf<\/h4>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>x &#061; [1, 2, 3, 4, 5]<br \/>\ny &#061; [2, 4, 6, 8, 10]<\/p>\n<p>plt.plot(x, y)<br \/>\nplt.show()<\/p>\n<p>\u8fd9\u4f1a\u5f39\u51fa\u4e00\u4e2a\u7a97\u53e3&#xff0c;\u663e\u793a\u4e00\u6761\u4ece\u5de6\u4e0b\u5230\u53f3\u4e0a\u7684\u76f4\u7ebf\u3002<\/p>\n<h4 id=\"42-\u591a\u6761\u7ebf\">4.2 \u591a\u6761\u7ebf<\/h4>\n<p>x &#061; [1, 2, 3, 4, 5]<br \/>\ny1 &#061; [2, 4, 6, 8, 10]<br \/>\ny2 &#061; [1, 3, 5, 7, 9]<\/p>\n<p>plt.plot(x, y1, label&#061;&#039;y&#061;2x&#039;)<br \/>\nplt.plot(x, y2, label&#061;&#039;y&#061;2x-1&#039;)<br \/>\nplt.legend()  # \u663e\u793a\u56fe\u4f8b<br \/>\nplt.show()<\/p>\n<h4 id=\"43-\u6837\u5f0f\u8bbe\u7f6e\">4.3 \u6837\u5f0f\u8bbe\u7f6e<\/h4>\n<p>plt.plot(x, y1, color&#061;&#039;red&#039;, linestyle&#061;&#039;&#8211;&#039;, marker&#061;&#039;o&#039;,<br \/>\n         linewidth&#061;2, markersize&#061;8, label&#061;&#039;\u7ea2\u8272\u865a\u7ebf&#039;)<br \/>\nplt.plot(x, y2, color&#061;&#039;blue&#039;, linestyle&#061;&#039;-&#039;, marker&#061;&#039;s&#039;,<br \/>\n         linewidth&#061;3, markersize&#061;6, label&#061;&#039;\u84dd\u8272\u5b9e\u7ebf&#039;)<br \/>\nplt.legend()<br \/>\nplt.show()<\/p>\n<p>\u6837\u5f0f\u53c2\u6570\u8bf4\u660e&#xff1a;<\/p>\n<table>\n<tr>\u53c2\u6570\u8bf4\u660e\u5e38\u7528\u503c<\/tr>\n<tbody>\n<tr>\n<td>color<\/td>\n<td>\u989c\u8272<\/td>\n<td>&#039;red&#039;\u3001&#039;#FF0000&#039;\u3001&#039;r&#039;<\/td>\n<\/tr>\n<tr>\n<td>linestyle<\/td>\n<td>\u7ebf\u578b<\/td>\n<td>&#039;-&#039;\u3001&#039;&#8211;&#039;\u3001&#039;-.&#039;\u3001&#039;:&#039;<\/td>\n<\/tr>\n<tr>\n<td>marker<\/td>\n<td>\u6807\u8bb0<\/td>\n<td>&#039;o&#039;\u3001&#039;s&#039;\u3001&#039;^&#039;\u3001&#039;D&#039;\u3001&#039;*&#039;<\/td>\n<\/tr>\n<tr>\n<td>linewidth<\/td>\n<td>\u7ebf\u5bbd<\/td>\n<td>\u6570\u5b57<\/td>\n<\/tr>\n<tr>\n<td>markersize<\/td>\n<td>\u6807\u8bb0\u5927\u5c0f<\/td>\n<td>\u6570\u5b57<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7b80\u5199\u683c\u5f0f&#xff1a;&#039;ro&#8211;&#039;\u00a0\u8868\u793a\u7ea2\u8272 &#043; \u5706\u5f62\u6807\u8bb0 &#043; \u865a\u7ebf\u3002<\/p>\n<p>plt.plot(x, y1, &#039;ro&#8211;&#039;, label&#061;&#039;\u7b80\u5199&#039;)<br \/>\nplt.show()<\/p>\n<h4 id=\"44-\u6807\u9898\u6807\u7b7e\u56fe\u4f8b\u7f51\u683c\">4.4 \u6807\u9898\u3001\u6807\u7b7e\u3001\u56fe\u4f8b\u3001\u7f51\u683c<\/h4>\n<p>plt.plot(x, y1, label&#061;&#039;\u9500\u91cf&#039;)<br \/>\nplt.title(&#039;\u6708\u5ea6\u9500\u91cf\u8d8b\u52bf&#039;, fontsize&#061;16)<br \/>\nplt.xlabel(&#039;\u6708\u4efd&#039;, fontsize&#061;12)<br \/>\nplt.ylabel(&#039;\u9500\u91cf&#xff08;\u4ef6&#xff09;&#039;, fontsize&#061;12)<br \/>\nplt.legend(loc&#061;&#039;upper left&#039;, fontsize&#061;10)<br \/>\nplt.grid(True, linestyle&#061;&#039;&#8211;&#039;, alpha&#061;0.5)<br \/>\nplt.xlim(0, 6)    # x\u8f74\u8303\u56f4<br \/>\nplt.ylim(0, 12)   # y\u8f74\u8303\u56f4<br \/>\nplt.show()<\/p>\n<h4 id=\"45-\u4fdd\u5b58\u548c\u663e\u793a\">4.5 \u4fdd\u5b58\u548c\u663e\u793a<\/h4>\n<p>plt.plot(x, y1)<br \/>\nplt.savefig(&#039;line.png&#039;, dpi&#061;150, bbox_inches&#061;&#039;tight&#039;)  # \u4fdd\u5b58\u56fe\u7247<br \/>\nplt.show()<br \/>\n# plt.close()  # \u5173\u95ed\u56fe\u5f62&#xff0c;\u91ca\u653e\u5185\u5b58<\/p>\n<p>dpi\u00a0\u63a7\u5236\u5206\u8fa8\u7387&#xff0c;bbox_inches&#061;&#039;tight&#039;\u00a0\u53bb\u9664\u591a\u4f59\u767d\u8fb9\u3002<\/p>\n<hr \/>\n<h3 id=\"\u4e94\u67f1\u72b6\u56fe-bar-\u548c-barh\">\u4e94\u3001\u67f1\u72b6\u56fe bar \u548c barh<\/h3>\n<h4 id=\"51-\u666e\u901a\u67f1\u72b6\u56fe\">5.1 \u666e\u901a\u67f1\u72b6\u56fe<\/h4>\n<p>categories &#061; [&#039;\u6280\u672f\u90e8&#039;, &#039;\u5e02\u573a\u90e8&#039;, &#039;\u8d22\u52a1\u90e8&#039;, &#039;\u4eba\u4e8b\u90e8&#039;]<br \/>\nvalues &#061; [15, 12, 8, 6]<\/p>\n<p>plt.bar(categories, values, color&#061;[&#039;#4CAF50&#039;, &#039;#2196F3&#039;, &#039;#FF9800&#039;, &#039;#F44336&#039;])<br \/>\nplt.title(&#039;\u5404\u90e8\u95e8\u4eba\u6570&#039;)<br \/>\nplt.ylabel(&#039;\u4eba\u6570&#039;)<br \/>\nfor i, v in enumerate(values):<br \/>\n    plt.text(i, v &#043; 0.3, str(v), ha&#061;&#039;center&#039;)  # \u5728\u67f1\u5b50\u4e0a\u6807\u6ce8\u6570\u503c<br \/>\nplt.show()<\/p>\n<h4 id=\"52-\u6a2a\u5411\u67f1\u72b6\u56fe\">5.2 \u6a2a\u5411\u67f1\u72b6\u56fe<\/h4>\n<p>plt.barh(categories, values, color&#061;&#039;skyblue&#039;)<br \/>\nplt.xlabel(&#039;\u4eba\u6570&#039;)<br \/>\nplt.show()<\/p>\n<h4 id=\"53-\u5806\u53e0\u67f1\u72b6\u56fe\">5.3 \u5806\u53e0\u67f1\u72b6\u56fe<\/h4>\n<p>men &#061; [12, 15, 10, 8]<br \/>\nwomen &#061; [8, 10, 12, 6]<\/p>\n<p>plt.bar(categories, men, label&#061;&#039;\u7537&#039;, color&#061;&#039;steelblue&#039;)<br \/>\nplt.bar(categories, women, bottom&#061;men, label&#061;&#039;\u5973&#039;, color&#061;&#039;pink&#039;)<br \/>\nplt.legend()<br \/>\nplt.title(&#039;\u5404\u90e8\u95e8\u7537\u5973\u4eba\u6570&#039;)<br \/>\nplt.show()<\/p>\n<h4 id=\"54-\u5206\u7ec4\u67f1\u72b6\u56fe\">5.4 \u5206\u7ec4\u67f1\u72b6\u56fe<\/h4>\n<p>import numpy as np<\/p>\n<p>x &#061; np.arange(len(categories))<br \/>\nwidth &#061; 0.35<\/p>\n<p>plt.bar(x &#8211; width\/2, men, width, label&#061;&#039;\u7537&#039;, color&#061;&#039;steelblue&#039;)<br \/>\nplt.bar(x &#043; width\/2, women, width, label&#061;&#039;\u5973&#039;, color&#061;&#039;pink&#039;)<br \/>\nplt.xticks(x, categories)<br \/>\nplt.legend()<br \/>\nplt.title(&#039;\u5404\u90e8\u95e8\u7537\u5973\u5bf9\u6bd4&#039;)<br \/>\nplt.show()<\/p>\n<hr \/>\n<h3 id=\"\u516d\u997c\u56fe-pie\">\u516d\u3001\u997c\u56fe pie<\/h3>\n<p>sizes &#061; [30, 25, 20, 15, 10]<br \/>\nlabels &#061; [&#039;\u6280\u672f\u90e8&#039;, &#039;\u5e02\u573a\u90e8&#039;, &#039;\u8d22\u52a1\u90e8&#039;, &#039;\u4eba\u4e8b\u90e8&#039;, &#039;\u5176\u4ed6&#039;]<br \/>\ncolors &#061; [&#039;#ff9999&#039;, &#039;#66b3ff&#039;, &#039;#99ff99&#039;, &#039;#ffcc99&#039;, &#039;#ffb3e6&#039;]<br \/>\nexplode &#061; (0.1, 0, 0, 0, 0)  # \u7a81\u51fa\u7b2c\u4e00\u5757<\/p>\n<p>plt.pie(sizes, explode&#061;explode, labels&#061;labels, colors&#061;colors,<br \/>\n        autopct&#061;&#039;%1.1f%%&#039;, shadow&#061;True, startangle&#061;90)<br \/>\nplt.axis(&#039;equal&#039;)  # \u5706\u5f62<br \/>\nplt.title(&#039;\u90e8\u95e8\u5360\u6bd4&#039;)<br \/>\nplt.show()<\/p>\n<p>\u8fd0\u884c\u6548\u679c&#xff1a;\u00a0\u4e00\u4e2a\u997c\u56fe&#xff0c;\u6280\u672f\u90e8\u90a3\u4e00\u5757\u88ab\u62c9\u51fa\u6765\u7a81\u51fa\u663e\u793a&#xff0c;\u6bcf\u5757\u6807\u6ce8\u767e\u5206\u6bd4\u3002<\/p>\n<hr \/>\n<h3 id=\"\u4e03\u76f4\u65b9\u56fe-hist\">\u4e03\u3001\u76f4\u65b9\u56fe hist<\/h3>\n<p>\u76f4\u65b9\u56fe\u7528\u4e8e\u5c55\u793a\u6570\u636e\u5206\u5e03\u3002<\/p>\n<p>import numpy as np<\/p>\n<p>scores &#061; np.random.normal(75, 10, 200)  # \u751f\u6210200\u4e2a\u6b63\u6001\u5206\u5e03\u6210\u7ee9<\/p>\n<p>plt.hist(scores, bins&#061;20, color&#061;&#039;skyblue&#039;, edgecolor&#061;&#039;black&#039;, alpha&#061;0.7)<br \/>\nplt.title(&#039;\u8003\u8bd5\u6210\u7ee9\u5206\u5e03&#039;)<br \/>\nplt.xlabel(&#039;\u5206\u6570&#039;)<br \/>\nplt.ylabel(&#039;\u4eba\u6570&#039;)<br \/>\nplt.axvline(np.mean(scores), color&#061;&#039;red&#039;, linestyle&#061;&#039;&#8211;&#039;, label&#061;f&#039;\u5e73\u5747\u5206{np.mean(scores):.1f}&#039;)<br \/>\nplt.legend()<br \/>\nplt.show()<\/p>\n<p>\u8bf4\u660e&#xff1a;\u00a0bins&#061;20\u00a0\u8868\u793a\u520620\u4e2a\u533a\u95f4&#xff0c;\u80fd\u770b\u51fa\u6210\u7ee9\u96c6\u4e2d\u5728 65-85 \u4e4b\u95f4&#xff0c;\u5448\u949f\u5f62\u5206\u5e03\u3002<\/p>\n<hr \/>\n<h3 id=\"\u516b\u6563\u70b9\u56fe-scatter\">\u516b\u3001\u6563\u70b9\u56fe scatter<\/h3>\n<p>\u6563\u70b9\u56fe\u7528\u4e8e\u89c2\u5bdf\u4e24\u4e2a\u53d8\u91cf\u7684\u76f8\u5173\u6027\u3002<\/p>\n<p>height &#061; np.random.normal(170, 8, 100)<br \/>\nweight &#061; height * 0.6 &#043; np.random.normal(-30, 5, 100)<\/p>\n<p>plt.scatter(height, weight, c&#061;&#039;purple&#039;, alpha&#061;0.6, s&#061;50)<br \/>\nplt.title(&#039;\u8eab\u9ad8\u4e0e\u4f53\u91cd\u5173\u7cfb&#039;)<br \/>\nplt.xlabel(&#039;\u8eab\u9ad8(cm)&#039;)<br \/>\nplt.ylabel(&#039;\u4f53\u91cd(kg)&#039;)<br \/>\nplt.show()<\/p>\n<p>\u8bf4\u660e&#xff1a;\u00a0\u70b9\u4ece\u5de6\u4e0b\u5230\u53f3\u4e0a\u5206\u5e03&#xff0c;\u8bf4\u660e\u8eab\u9ad8\u548c\u4f53\u91cd\u6b63\u76f8\u5173\u3002<\/p>\n<p>\u5e26\u989c\u8272\u6620\u5c04\u7684\u6563\u70b9\u56fe&#xff1a;<\/p>\n<p>x &#061; np.random.rand(100)<br \/>\ny &#061; np.random.rand(100)<br \/>\ncolors &#061; np.random.rand(100)<br \/>\nsizes &#061; 1000 * np.random.rand(100)<\/p>\n<p>plt.scatter(x, y, c&#061;colors, s&#061;sizes, alpha&#061;0.5, cmap&#061;&#039;viridis&#039;)<br \/>\nplt.colorbar()  # \u989c\u8272\u6761<br \/>\nplt.show()<\/p>\n<hr \/>\n<h3 id=\"\u4e5d\u7bb1\u7ebf\u56fe-box\">\u4e5d\u3001\u7bb1\u7ebf\u56fe box<\/h3>\n<p>\u7bb1\u7ebf\u56fe\u7528\u4e8e\u68c0\u6d4b\u79bb\u7fa4\u503c&#xff08;\u5f02\u5e38\u503c&#xff09;\u3002<\/p>\n<p>data &#061; [np.random.normal(0, std, 100) for std in range(1, 5)]<\/p>\n<p>plt.boxplot(data, labels&#061;[&#039;A&#039;, &#039;B&#039;, &#039;C&#039;, &#039;D&#039;])<br \/>\nplt.title(&#039;\u5404\u7ec4\u6570\u636e\u5206\u5e03&#039;)<br \/>\nplt.ylabel(&#039;\u503c&#039;)<br \/>\nplt.show()<\/p>\n<p>\u5982\u4f55\u770b\u7bb1\u7ebf\u56fe&#xff1a;<\/p>\n<ul>\n<li>\u7bb1\u5b50\u4e0a\u4e0b\u8fb9&#xff1a;\u4e0a\u4e0b\u56db\u5206\u4f4d\u6570&#xff08;Q3\u3001Q1&#xff09;<\/li>\n<li>\u7bb1\u5185\u6a2a\u7ebf&#xff1a;\u4e2d\u4f4d\u6570<\/li>\n<li>\u4e0a\u4e0b\u987b&#xff1a;\u6b63\u5e38\u8303\u56f4\u8fb9\u754c<\/li>\n<li>\u5706\u70b9&#xff1a;\u79bb\u7fa4\u503c&#xff08;\u5f02\u5e38\u70b9&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"\u5341\u5b50\u56fe-subplots\">\u5341\u3001\u5b50\u56fe subplots<\/h3>\n<p>\u4e00\u5f20\u56fe\u91cc\u753b\u591a\u4e2a\u5b50\u56fe\u3002<\/p>\n<p>fig, axes &#061; plt.subplots(2, 2, figsize&#061;(10, 8))<\/p>\n<p>x &#061; np.linspace(0, 10, 100)<\/p>\n<p>axes[0, 0].plot(x, np.sin(x))<br \/>\naxes[0, 0].set_title(&#039;sin(x)&#039;)<\/p>\n<p>axes[0, 1].plot(x, np.cos(x), &#039;r&#039;)<br \/>\naxes[0, 1].set_title(&#039;cos(x)&#039;)<\/p>\n<p>axes[1, 0].plot(x, x**2)<br \/>\naxes[1, 0].set_title(&#039;x\u00b2&#039;)<\/p>\n<p>axes[1, 1].plot(x, np.log(x &#043; 1), &#039;g&#039;)<br \/>\naxes[1, 1].set_title(&#039;ln(x&#043;1)&#039;)<\/p>\n<p>plt.tight_layout()  # \u81ea\u52a8\u8c03\u6574\u95f4\u8ddd<br \/>\nplt.show()<\/p>\n<p>\u5171\u4eab x \u8f74&#xff1a;<\/p>\n<p>fig, (ax1, ax2) &#061; plt.subplots(2, 1, sharex&#061;True, figsize&#061;(8, 6))<br \/>\nax1.plot(x, np.sin(x))<br \/>\nax2.plot(x, np.cos(x))<br \/>\nplt.show()<\/p>\n<hr \/>\n<h3 id=\"\u5341\u4e00\u914d\u5408-pandas-\u753b\u56fe\">\u5341\u4e00\u3001\u914d\u5408 pandas \u753b\u56fe<\/h3>\n<p>pandas \u5185\u7f6e\u4e86\u00a0.plot()\u00a0\u65b9\u6cd5&#xff0c;\u5e95\u5c42\u8c03\u7528 matplotlib&#xff0c;\u66f4\u7b80\u6d01\u3002<\/p>\n<p>import pandas as pd<\/p>\n<p>df &#061; pd.DataFrame({<br \/>\n    &#039;\u6708\u4efd&#039;: [&#039;1\u6708&#039;, &#039;2\u6708&#039;, &#039;3\u6708&#039;, &#039;4\u6708&#039;, &#039;5\u6708&#039;, &#039;6\u6708&#039;],<br \/>\n    &#039;\u9500\u91cf&#039;: [120, 150, 180, 200, 170, 210],<br \/>\n    &#039;\u5229\u6da6&#039;: [12, 18, 25, 30, 22, 35]<br \/>\n})<br \/>\ndf &#061; df.set_index(&#039;\u6708\u4efd&#039;)<\/p>\n<p># \u6298\u7ebf\u56fe<br \/>\ndf.plot(kind&#061;&#039;line&#039;, marker&#061;&#039;o&#039;)<br \/>\nplt.title(&#039;\u4e0a\u534a\u5e74\u9500\u91cf\u4e0e\u5229\u6da6&#039;)<br \/>\nplt.show()<\/p>\n<p># \u67f1\u72b6\u56fe<br \/>\ndf.plot(kind&#061;&#039;bar&#039;)<br \/>\nplt.show()<\/p>\n<p># \u9762\u79ef\u56fe<br \/>\ndf.plot(kind&#061;&#039;area&#039;, alpha&#061;0.5)<br \/>\nplt.show()<\/p>\n<p># \u76f4\u65b9\u56fe<br \/>\ndf[&#039;\u9500\u91cf&#039;].plot(kind&#061;&#039;hist&#039;, bins&#061;10)<br \/>\nplt.show()<\/p>\n<p>kind \u53c2\u6570\u53ef\u9009\u503c&#xff1a;\u00a0line\u3001bar\u3001barh\u3001hist\u3001box\u3001area\u3001scatter\u3001pie\u3001kde\u3002<\/p>\n<hr \/>\n<h3 id=\"\u5341\u4e8c\u4e2d\u6587\u663e\u793a\u95ee\u9898\">\u5341\u4e8c\u3001\u4e2d\u6587\u663e\u793a\u95ee\u9898<\/h3>\n<p>matplotlib \u9ed8\u8ba4\u4e0d\u652f\u6301\u4e2d\u6587&#xff0c;\u6807\u9898\u4f1a\u663e\u793a\u4e3a\u65b9\u6846\u3002\u89e3\u51b3\u65b9\u6cd5&#xff1a;<\/p>\n<h4 id=\"macos-\u65b9\u6848\">macOS \u65b9\u6848<\/h4>\n<p>import matplotlib.pyplot as plt<br \/>\nplt.rcParams[&#039;font.sans-serif&#039;] &#061; [&#039;Arial Unicode MS&#039;]<br \/>\nplt.rcParams[&#039;axes.unicode_minus&#039;] &#061; False  # \u8d1f\u53f7\u6b63\u5e38\u663e\u793a<\/p>\n<h4 id=\"windows-\u65b9\u6848\">Windows \u65b9\u6848<\/h4>\n<p>plt.rcParams[&#039;font.sans-serif&#039;] &#061; [&#039;SimHei&#039;]  # \u9ed1\u4f53<br \/>\nplt.rcParams[&#039;axes.unicode_minus&#039;] &#061; False<\/p>\n<h4 id=\"\u901a\u7528\u65b9\u6848\u67e5\u627e\u7cfb\u7edf\u5b57\u4f53\">\u901a\u7528\u65b9\u6848&#xff08;\u67e5\u627e\u7cfb\u7edf\u5b57\u4f53&#xff09;<\/h4>\n<p>from matplotlib import font_manager<br \/>\nfonts &#061; [f.name for f in font_manager.fontManager.ttflist]<br \/>\nprint([f for f in set(fonts) if &#039;Hei&#039; in f or &#039;Song&#039; in f or &#039;Unicode&#039; in f])<\/p>\n<p>\u6d4b\u8bd5&#xff1a;<\/p>\n<p>plt.rcParams[&#039;font.sans-serif&#039;] &#061; [&#039;Arial Unicode MS&#039;]<br \/>\nplt.rcParams[&#039;axes.unicode_minus&#039;] &#061; False<\/p>\n<p>plt.plot([1, 2, 3], [4, 5, 6])<br \/>\nplt.title(&#039;\u4e2d\u6587\u6807\u9898\u6b63\u5e38\u663e\u793a&#039;)<br \/>\nplt.xlabel(&#039;\u6a2a\u8f74\u6807\u7b7e&#039;)<br \/>\nplt.show()<\/p>\n<hr \/>\n<h3 id=\"\u5341\u4e09\u6837\u5f0f\u7f8e\u5316\">\u5341\u4e09\u3001\u6837\u5f0f\u7f8e\u5316<\/h3>\n<h4 id=\"131-\u5185\u7f6e\u6837\u5f0f\">13.1 \u5185\u7f6e\u6837\u5f0f<\/h4>\n<p>print(plt.style.available)<br \/>\n# [&#039;Solarize_Light2&#039;, &#039;seaborn-v0_8&#039;, &#039;ggplot&#039;, &#039;grayscale&#039;, &#039;dark_background&#039;, &#8230;]<\/p>\n<p>plt.style.use(&#039;ggplot&#039;)  # \u4f7f\u7528ggplot\u98ce\u683c<br \/>\nplt.plot([1, 2, 3], [4, 5, 6])<br \/>\nplt.show()<\/p>\n<p>plt.style.use(&#039;dark_background&#039;)  # \u6697\u8272\u80cc\u666f<br \/>\nplt.plot([1, 2, 3], [4, 5, 6])<br \/>\nplt.show()<\/p>\n<h4 id=\"132-seaborn-\u98ce\u683c\">13.2 seaborn \u98ce\u683c<\/h4>\n<p>plt.style.use(&#039;seaborn-v0_8-darkgrid&#039;)<br \/>\nplt.plot([1, 2, 3], [4, 5, 6])<br \/>\nplt.show()<\/p>\n<h4 id=\"133-\u4e34\u65f6\u6837\u5f0f\">13.3 \u4e34\u65f6\u6837\u5f0f<\/h4>\n<p>with plt.style.context(&#039;ggplot&#039;):<br \/>\n    plt.plot([1, 2, 3], [4, 5, 6])<br \/>\n    plt.show()<br \/>\n# \u9000\u51fawith\u540e\u6062\u590d\u9ed8\u8ba4<\/p>\n<hr \/>\n<h3 id=\"\u5341\u56db\u8fdb\u9636seaborn-\u7b80\u4ecb\">\u5341\u56db\u3001\u8fdb\u9636&#xff1a;seaborn \u7b80\u4ecb<\/h3>\n<p>seaborn \u57fa\u4e8e matplotlib&#xff0c;\u63d0\u4f9b\u66f4\u7f8e\u89c2\u7684\u7edf\u8ba1\u56fe\u8868&#xff0c;\u9ed8\u8ba4\u6837\u5f0f\u66f4\u6f02\u4eae\u3002<\/p>\n<p>pip install seaborn<\/p>\n<p>import seaborn as sns<br \/>\nimport pandas as pd<br \/>\nimport matplotlib.pyplot as plt<\/p>\n<p># \u51c6\u5907\u6570\u636e<br \/>\ndf &#061; pd.DataFrame({<br \/>\n    &#039;department&#039;: [&#039;\u6280\u672f&#039;, &#039;\u6280\u672f&#039;, &#039;\u5e02\u573a&#039;, &#039;\u5e02\u573a&#039;, &#039;\u8d22\u52a1&#039;, &#039;\u8d22\u52a1&#039;],<br \/>\n    &#039;salary&#039;: [8000, 9500, 12000, 11000, 15000, 14000]<br \/>\n})<\/p>\n<p># \u7bb1\u7ebf\u56fe<br \/>\nsns.boxplot(x&#061;&#039;department&#039;, y&#061;&#039;salary&#039;, data&#061;df)<br \/>\nplt.show()<\/p>\n<p># \u5c0f\u63d0\u7434\u56fe<br \/>\nsns.violinplot(x&#061;&#039;department&#039;, y&#061;&#039;salary&#039;, data&#061;df)<br \/>\nplt.show()<\/p>\n<h4 id=\"\u70ed\u529b\u56fe\">\u70ed\u529b\u56fe<\/h4>\n<p>import numpy as np<br \/>\ndata &#061; np.random.rand(5, 5)<br \/>\nsns.heatmap(data, annot&#061;True, cmap&#061;&#039;YlOrRd&#039;)<br \/>\nplt.title(&#039;\u70ed\u529b\u56fe&#039;)<br \/>\nplt.show()<\/p>\n<h4 id=\"pairplot\u591a\u53d8\u91cf\u5173\u7cfb\u77e9\u9635\">pairplot&#xff08;\u591a\u53d8\u91cf\u5173\u7cfb\u77e9\u9635&#xff09;<\/h4>\n<p>iris &#061; sns.load_dataset(&#039;iris&#039;)<br \/>\nsns.pairplot(iris, hue&#061;&#039;species&#039;)<br \/>\nplt.show()<\/p>\n<hr \/>\n<h3 id=\"\u5341\u4e94\u8fdb\u9636plotly-\u4ea4\u4e92\u5f0f\u56fe\u8868\">\u5341\u4e94\u3001\u8fdb\u9636&#xff1a;plotly \u4ea4\u4e92\u5f0f\u56fe\u8868<\/h3>\n<p>plotly \u53ef\u4ee5\u751f\u6210\u4ea4\u4e92\u5f0f HTML \u56fe\u8868&#xff0c;\u652f\u6301\u7f29\u653e\u3001\u60ac\u505c\u67e5\u770b\u6570\u636e\u3002<\/p>\n<p>pip install plotly<\/p>\n<p>import plotly.express as px<\/p>\n<p>df &#061; px.data.gapminder().query(&#034;country in [&#039;China&#039;, &#039;India&#039;, &#039;United States&#039;]&#034;)<br \/>\nfig &#061; px.line(df, x&#061;&#039;year&#039;, y&#061;&#039;gdpPercap&#039;, color&#061;&#039;country&#039;,<br \/>\n              title&#061;&#039;\u4eba\u5747GDP\u8d8b\u52bf&#039;)<br \/>\nfig.show()  # \u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00&#xff0c;\u53ef\u4ea4\u4e92<\/p>\n<p>\u4f18\u52bf&#xff1a;\u00a0\u9f20\u6807\u60ac\u505c\u663e\u793a\u6570\u503c\u3001\u53ef\u7f29\u653e\u3001\u53ef\u5bfc\u51fa HTML \u5206\u4eab\u3002<\/p>\n<hr \/>\n<h3 id=\"\u5341\u516d\u5b9e\u6218\u6848\u4f8b\u9500\u552e\u6570\u636e\u53ef\u89c6\u5316\u4eea\u8868\u76d8\">\u5341\u516d\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;\u9500\u552e\u6570\u636e\u53ef\u89c6\u5316\u4eea\u8868\u76d8<\/h3>\n<p>\u628a\u591a\u79cd\u56fe\u8868\u7ec4\u5408\u6210\u4e00\u4e2a\u4eea\u8868\u76d8\u3002<\/p>\n<p>import matplotlib.pyplot as plt<br \/>\nimport numpy as np<br \/>\nimport pandas as pd<\/p>\n<p>plt.rcParams[&#039;font.sans-serif&#039;] &#061; [&#039;Arial Unicode MS&#039;]<br \/>\nplt.rcParams[&#039;axes.unicode_minus&#039;] &#061; False<\/p>\n<p># \u6a21\u62df\u9500\u552e\u6570\u636e<br \/>\nnp.random.seed(42)<br \/>\nmonths &#061; [&#039;1\u6708&#039;, &#039;2\u6708&#039;, &#039;3\u6708&#039;, &#039;4\u6708&#039;, &#039;5\u6708&#039;, &#039;6\u6708&#039;]<br \/>\nsales &#061; np.random.randint(100, 300, 6)<br \/>\nproducts &#061; [&#039;\u624b\u673a&#039;, &#039;\u7535\u8111&#039;, &#039;\u5e73\u677f&#039;, &#039;\u8033\u673a&#039;]<br \/>\nproduct_sales &#061; np.random.randint(50, 200, 4)<br \/>\nregions &#061; [&#039;\u534e\u5317&#039;, &#039;\u534e\u4e1c&#039;, &#039;\u534e\u5357&#039;, &#039;\u534e\u897f&#039;]<br \/>\nregion_sales &#061; np.random.randint(80, 250, 4)<\/p>\n<p># \u521b\u5efa2&#215;2\u4eea\u8868\u76d8<br \/>\nfig, axes &#061; plt.subplots(2, 2, figsize&#061;(12, 10))<br \/>\nfig.suptitle(&#039;2024\u5e74\u4e0a\u534a\u5e74\u9500\u552e\u4eea\u8868\u76d8&#039;, fontsize&#061;18, fontweight&#061;&#039;bold&#039;)<\/p>\n<p># 1. \u6708\u5ea6\u8d8b\u52bf\u6298\u7ebf\u56fe<br \/>\naxes[0, 0].plot(months, sales, &#039;o-&#039;, color&#061;&#039;#2196F3&#039;, linewidth&#061;2, markersize&#061;8)<br \/>\naxes[0, 0].fill_between(range(6), sales, alpha&#061;0.2, color&#061;&#039;#2196F3&#039;)<br \/>\naxes[0, 0].set_title(&#039;\u6708\u5ea6\u9500\u552e\u989d\u8d8b\u52bf&#039;)<br \/>\naxes[0, 0].set_ylabel(&#039;\u9500\u552e\u989d&#xff08;\u4e07\u5143&#xff09;&#039;)<br \/>\nfor i, v in enumerate(sales):<br \/>\n    axes[0, 0].text(i, v &#043; 5, str(v), ha&#061;&#039;center&#039;)<\/p>\n<p># 2. \u4ea7\u54c1\u9500\u91cf\u67f1\u72b6\u56fe<br \/>\naxes[0, 1].bar(products, product_sales, color&#061;[&#039;#4CAF50&#039;, &#039;#2196F3&#039;, &#039;#FF9800&#039;, &#039;#F44336&#039;])<br \/>\naxes[0, 1].set_title(&#039;\u5404\u4ea7\u54c1\u9500\u91cf&#039;)<br \/>\naxes[0, 1].set_ylabel(&#039;\u9500\u91cf&#xff08;\u4ef6&#xff09;&#039;)<\/p>\n<p># 3. \u533a\u57df\u5360\u6bd4\u997c\u56fe<br \/>\naxes[1, 0].pie(region_sales, labels&#061;regions, autopct&#061;&#039;%1.1f%%&#039;,<br \/>\n               colors&#061;[&#039;#ff9999&#039;, &#039;#66b3ff&#039;, &#039;#99ff99&#039;, &#039;#ffcc99&#039;])<br \/>\naxes[1, 0].set_title(&#039;\u5404\u533a\u57df\u9500\u552e\u5360\u6bd4&#039;)<\/p>\n<p># 4. \u9500\u91cf\u5206\u5e03\u76f4\u65b9\u56fe<br \/>\nall_sales &#061; np.random.normal(150, 40, 200)<br \/>\naxes[1, 1].hist(all_sales, bins&#061;20, color&#061;&#039;skyblue&#039;, edgecolor&#061;&#039;black&#039;, alpha&#061;0.7)<br \/>\naxes[1, 1].axvline(np.mean(all_sales), color&#061;&#039;red&#039;, linestyle&#061;&#039;&#8211;&#039;, label&#061;&#039;\u5e73\u5747\u503c&#039;)<br \/>\naxes[1, 1].set_title(&#039;\u9500\u91cf\u5206\u5e03&#039;)<br \/>\naxes[1, 1].set_xlabel(&#039;\u9500\u91cf&#039;)<br \/>\naxes[1, 1].set_ylabel(&#039;\u9891\u6b21&#039;)<br \/>\naxes[1, 1].legend()<\/p>\n<p>plt.tight_layout()<br \/>\nplt.savefig(&#039;dashboard.png&#039;, dpi&#061;150, bbox_inches&#061;&#039;tight&#039;)<br \/>\nplt.show()<br \/>\nprint(&#034;\u4eea\u8868\u76d8\u5df2\u4fdd\u5b58\u4e3a dashboard.png&#034;)<\/p>\n<p>\u8fd0\u884c\u6548\u679c&#xff1a;\u00a0\u751f\u6210\u4e00\u5f20 2\u00d72 \u7684\u4eea\u8868\u76d8\u56fe\u7247&#xff0c;\u5305\u542b\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u3001\u997c\u56fe\u3001\u76f4\u65b9\u56fe&#xff0c;\u6807\u9898\u4e3a&#034;2024\u5e74\u4e0a\u534a\u5e74\u9500\u552e\u4eea\u8868\u76d8&#034;&#xff0c;\u4fdd\u5b58\u4e3a\u00a0dashboard.png\u3002<\/p>\n<hr \/>\n<h3 id=\"\u5341\u4e03\u6700\u4f73\u5b9e\u8df5\">\u5341\u4e03\u3001\u6700\u4f73\u5b9e\u8df5<\/h3>\n<li>\u5148\u60f3\u518d\u753b&#xff1a;\u660e\u786e\u8981\u8868\u8fbe\u4ec0\u4e48&#xff08;\u8d8b\u52bf\u7528\u6298\u7ebf\u3001\u5bf9\u6bd4\u7528\u67f1\u72b6\u3001\u5360\u6bd4\u7528\u997c\u56fe\u3001\u5206\u5e03\u7528\u76f4\u65b9\u56fe&#xff09;\u3002<\/li>\n<li>\u56fe\u8868\u7c7b\u578b\u9009\u62e9&#xff1a;\n<ul>\n<li>\u8d8b\u52bf\u53d8\u5316 \u2192 \u6298\u7ebf\u56fe<\/li>\n<li>\u5206\u7c7b\u5bf9\u6bd4 \u2192 \u67f1\u72b6\u56fe<\/li>\n<li>\u5360\u6bd4\u6784\u6210 \u2192 \u997c\u56fe<\/li>\n<li>\u6570\u636e\u5206\u5e03 \u2192 \u76f4\u65b9\u56fe\/\u7bb1\u7ebf\u56fe<\/li>\n<li>\u76f8\u5173\u5173\u7cfb \u2192 \u6563\u70b9\u56fe<\/li>\n<\/ul>\n<\/li>\n<li>\u5c11\u5373\u662f\u591a&#xff1a;\u4e00\u5f20\u56fe\u522b\u653e\u592a\u591a\u4fe1\u606f&#xff0c;\u5fc5\u8981\u65f6\u7528\u5b50\u56fe\u3002<\/li>\n<li>\u6807\u6ce8\u8981\u5168&#xff1a;\u6807\u9898\u3001\u8f74\u6807\u7b7e\u3001\u5355\u4f4d\u3001\u56fe\u4f8b\u4e0d\u80fd\u5c11\u3002<\/li>\n<li>\u914d\u8272\u534f\u8c03&#xff1a;\u7528\u8272\u76f2\u53cb\u597d\u914d\u8272&#xff0c;\u907f\u514d\u7ea2\u7eff\u540c\u65f6\u7528\u3002<\/li>\n<li>\u4fdd\u5b58\u7528 dpi&#xff1a;dpi&#061;150\u00a0\u4ee5\u4e0a\u4fdd\u8bc1\u6e05\u6670\u3002<\/li>\n<li>\u4e2d\u6587\u8bbe\u7f6e\u653e\u6700\u524d&#xff1a;\u5728\u6240\u6709\u7ed8\u56fe\u4ee3\u7801\u4e4b\u524d\u8bbe\u7f6e\u5b57\u4f53\u3002<\/li>\n<li>\u4ea4\u4e92\u7528 plotly&#xff1a;\u9700\u8981\u7f29\u653e\u3001\u60ac\u505c\u65f6\u7528 plotly \u800c\u975e matplotlib\u3002<\/li>\n<p># \u914d\u8272\u65b9\u6848\u63a8\u8350<br \/>\ncolors &#061; [&#039;#4CAF50&#039;, &#039;#2196F3&#039;, &#039;#FF9800&#039;, &#039;#F44336&#039;, &#039;#9C27B0&#039;]<\/p>\n<hr \/>\n<h3 id=\"\u5341\u516b\u5c0f\u7ed3\"><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00&#xff1a;\u4e0a\u7bc7\u6211\u4eec\u5b66\u4f1a\u4e86\u7528 pandas \u5904\u7406\u8868\u683c\u6570\u636e&#xff0c;\u4f46\u8868\u683c\u91cc\u5168\u662f\u6570\u5b57&#xff0c;\u4e0d\u591f\u76f4\u89c2\u3002\u4fd7\u8bdd\u8bf4\\&#8221;\u4e00\u56fe\u80dc\u5343\u8a00\\&#8221;&#xff0c;\u6570\u636e\u53ef\u89c6\u5316\u80fd\u628a\u67af\u71e5\u7684\u6570\u5b57\u53d8\u6210\u76f4\u89c2\u7684\u56fe\u8868&#xff0c;\u8ba9\u4eba\u4e00\u773c\u770b\u51fa\u8d8b\u52bf\u3001\u5206\u5e03\u548c\u5f02\u5e38\u3002\u672c\u7bc7\u5e26\u4f60\u638c\u63e1 Python \u6700\u7ecf\u5178\u7684\u7ed8\u56fe\u5e93\u2014\u2014matplotlib\u3002\u4e00\u3001\u4e3a\u4ec0\u4e48\u8981\u753b\u56fe\u4eba\u7c7b\u5927\u8111\u5bf9\u56fe\u5f62\u7684\u611f\u77e5\u8fdc\u5feb\u4e8e\u5bf9\u6570\u5b57\u7684\u611f\u77e5\u3002\u8003\u8651\u8fd9\u4e24\u7ec4\u6570\u636e&#xff1a;A: [12, 15, 18, 22, 25, 30, 35, 40, 38, 42<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13178,2468,81,1224],"topic":[],"class_list":["post-119819","post","type-post","status-publish","format-standard","hentry","category-server","tag-1024---","tag-matplotlib","tag-python","tag-1224"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/119819.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00&#xff1a;\u4e0a\u7bc7\u6211\u4eec\u5b66\u4f1a\u4e86\u7528 pandas \u5904\u7406\u8868\u683c\u6570\u636e&#xff0c;\u4f46\u8868\u683c\u91cc\u5168\u662f\u6570\u5b57&#xff0c;\u4e0d\u591f\u76f4\u89c2\u3002\u4fd7\u8bdd\u8bf4&quot;\u4e00\u56fe\u80dc\u5343\u8a00&quot;&#xff0c;\u6570\u636e\u53ef\u89c6\u5316\u80fd\u628a\u67af\u71e5\u7684\u6570\u5b57\u53d8\u6210\u76f4\u89c2\u7684\u56fe\u8868&#xff0c;\u8ba9\u4eba\u4e00\u773c\u770b\u51fa\u8d8b\u52bf\u3001\u5206\u5e03\u548c\u5f02\u5e38\u3002\u672c\u7bc7\u5e26\u4f60\u638c\u63e1 Python \u6700\u7ecf\u5178\u7684\u7ed8\u56fe\u5e93\u2014\u2014matplotlib\u3002\u4e00\u3001\u4e3a\u4ec0\u4e48\u8981\u753b\u56fe\u4eba\u7c7b\u5927\u8111\u5bf9\u56fe\u5f62\u7684\u611f\u77e5\u8fdc\u5feb\u4e8e\u5bf9\u6570\u5b57\u7684\u611f\u77e5\u3002\u8003\u8651\u8fd9\u4e24\u7ec4\u6570\u636e&#xff1a;A: [12, 15, 18, 22, 25, 30, 35, 40, 38, 42\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/119819.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-30T06:24:49+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119819.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/119819.html\",\"name\":\"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-30T06:24:49+00:00\",\"dateModified\":\"2026-10-30T06:24:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/119819.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/119819.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119819.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/119819.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00&#xff1a;\u4e0a\u7bc7\u6211\u4eec\u5b66\u4f1a\u4e86\u7528 pandas \u5904\u7406\u8868\u683c\u6570\u636e&#xff0c;\u4f46\u8868\u683c\u91cc\u5168\u662f\u6570\u5b57&#xff0c;\u4e0d\u591f\u76f4\u89c2\u3002\u4fd7\u8bdd\u8bf4\"\u4e00\u56fe\u80dc\u5343\u8a00\"&#xff0c;\u6570\u636e\u53ef\u89c6\u5316\u80fd\u628a\u67af\u71e5\u7684\u6570\u5b57\u53d8\u6210\u76f4\u89c2\u7684\u56fe\u8868&#xff0c;\u8ba9\u4eba\u4e00\u773c\u770b\u51fa\u8d8b\u52bf\u3001\u5206\u5e03\u548c\u5f02\u5e38\u3002\u672c\u7bc7\u5e26\u4f60\u638c\u63e1 Python \u6700\u7ecf\u5178\u7684\u7ed8\u56fe\u5e93\u2014\u2014matplotlib\u3002\u4e00\u3001\u4e3a\u4ec0\u4e48\u8981\u753b\u56fe\u4eba\u7c7b\u5927\u8111\u5bf9\u56fe\u5f62\u7684\u611f\u77e5\u8fdc\u5feb\u4e8e\u5bf9\u6570\u5b57\u7684\u611f\u77e5\u3002\u8003\u8651\u8fd9\u4e24\u7ec4\u6570\u636e&#xff1a;A: [12, 15, 18, 22, 25, 30, 35, 40, 38, 42","og_url":"https:\/\/www.wsisp.com\/helps\/119819.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-30T06:24:49+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/119819.html","url":"https:\/\/www.wsisp.com\/helps\/119819.html","name":"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-30T06:24:49+00:00","dateModified":"2026-10-30T06:24:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/119819.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/119819.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/119819.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Python\u3011\u57fa\u7840\u8bed\u6cd5\u5165\u95e8\uff08\u4e09\u5341\u4e94\uff09\u2014\u2014 \u6570\u636e\u53ef\u89c6\u5316\uff1a\u7528 matplotlib \u753b\u56fe"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=119819"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119819\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=119819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=119819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=119819"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=119819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}