{"id":965834,"date":"2024-12-27T04:41:47","date_gmt":"2024-12-26T20:41:47","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/965834.html"},"modified":"2024-12-27T04:41:50","modified_gmt":"2024-12-26T20:41:50","slug":"python%e7%94%bb%e5%9b%be%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9%e5%ad%97%e4%bd%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/965834.html","title":{"rendered":"python\u753b\u56fe\u5982\u4f55\u4fee\u6539\u5b57\u4f53"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24181934\/38cbc677-598e-4890-9cde-eb830496f083.webp\" alt=\"python\u753b\u56fe\u5982\u4f55\u4fee\u6539\u5b57\u4f53\" \/><\/p>\n<p><p> \u5f00\u5934\u6bb5\u843d\uff1a<br \/>\u5728Python\u4e2d\u7ed8\u5236\u56fe\u5f62\u65f6\uff0c<strong>\u4fee\u6539\u5b57\u4f53\u7684\u65b9\u5f0f\u5305\u62ec\u4f7f\u7528matplotlib\u5e93\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027\u3001\u5229\u7528\u5b57\u4f53\u7ba1\u7406\u5668\u52a0\u8f7d\u81ea\u5b9a\u4e49\u5b57\u4f53\u3001\u5728\u7ed8\u56fe\u51fd\u6570\u4e2d\u76f4\u63a5\u6307\u5b9a\u5b57\u4f53\u53c2\u6570<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u662f\u901a\u8fc7matplotlib\u5e93\u7684<code>rcParams<\/code>\u548c<code>font_manager<\/code>\u6a21\u5757\u4fee\u6539\u5168\u5c40\u6216\u5c40\u90e8\u5b57\u4f53\u6837\u5f0f\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>rcParams<\/code>\u53ef\u4ee5\u5168\u5c40\u4fee\u6539\u5b57\u4f53\u5c5e\u6027\uff0c\u8fd9\u6837\u5728\u7ed8\u5236\u591a\u5f20\u56fe\u65f6\u65e0\u9700\u6bcf\u6b21\u6307\u5b9a\u5b57\u4f53\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Python\u4e2d\u901a\u8fc7\u4e0d\u540c\u7684\u65b9\u6cd5\u4fee\u6539\u7ed8\u56fe\u7684\u5b57\u4f53\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001MATPLOTLIB\u5e93\u7684\u57fa\u7840\u5b57\u4f53\u8bbe\u7f6e<\/p>\n<\/p>\n<p><p>Matplotlib\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u7ed8\u56fe\u5e93\u4e4b\u4e00\uff0c\u5b83\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u5f0f\u6765\u8c03\u6574\u5b57\u4f53\u8bbe\u7f6e\u3002\u901a\u8fc7<code>rcParams<\/code>\uff0c\u6211\u4eec\u53ef\u4ee5\u5168\u5c40\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027\uff0c\u4f7f\u5f97\u6240\u6709\u56fe\u5f62\u90fd\u9075\u5faa\u76f8\u540c\u7684\u5b57\u4f53\u98ce\u683c\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>rcParams<\/code>\u6765\u8bbe\u7f6e\u5168\u5c40\u5b57\u4f53\u3002\u8fd9\u4e2a\u65b9\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u5728\u7ed8\u56fe\u4ee3\u7801\u7684\u6700\u5f00\u59cb\u52a0\u5165\u4ee5\u4e0b\u51e0\u884c\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>plt.rcParams[&#39;font.family&#39;] = &#39;sans-serif&#39;<\/p>\n<p>plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;Arial&#39;]<\/p>\n<p>plt.rcParams[&#39;font.size&#39;] = 12<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u5f0f\u4f1a\u5f71\u54cd\u6240\u6709\u7684\u56fe\u5f62\uff0c\u5305\u62ec\u6807\u9898\u3001\u6807\u7b7e\u548c\u523b\u5ea6\u7b49\u3002\u901a\u8fc7<code>rcParams<\/code>\uff0c\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u5b57\u4f53\u7684\u65cf\uff08\u5982sans-serif\u3001serif\uff09\u3001\u5177\u4f53\u7684\u5b57\u4f53\u540d\u79f0\uff08\u5982Arial\u3001Times New Roman\uff09\u548c\u5b57\u4f53\u5927\u5c0f\u7b49\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528FONT_MANAGER\u52a0\u8f7d\u81ea\u5b9a\u4e49\u5b57\u4f53<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u80fd\u5e0c\u671b\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\uff0c\u8fd9\u4e9b\u5b57\u4f53\u53ef\u80fd\u4e0d\u5728matplotlib\u9ed8\u8ba4\u652f\u6301\u7684\u8303\u56f4\u5185\u3002\u8fd9\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>font_manager<\/code>\u6a21\u5757\u6765\u52a0\u8f7d\u548c\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u786e\u4fdd\u8be5\u5b57\u4f53\u5df2\u5b89\u88c5\u5728\u7cfb\u7edf\u4e0a\u6216\u63d0\u4f9b\u5b57\u4f53\u6587\u4ef6\u7684\u8def\u5f84\u3002\u7136\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>font_manager<\/code>\u52a0\u8f7d\u5b57\u4f53\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from matplotlib import font_manager as fm<\/p>\n<h2><strong>\u52a0\u8f7d\u81ea\u5b9a\u4e49\u5b57\u4f53<\/strong><\/h2>\n<p>font_path = &#39;\/path\/to\/your\/font.ttf&#39;<\/p>\n<p>prop = fm.FontProperties(fname=font_path)<\/p>\n<h2><strong>\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53<\/strong><\/h2>\n<p>plt.title(&#39;Title&#39;, fontproperties=prop)<\/p>\n<p>plt.xlabel(&#39;X-axis&#39;, fontproperties=prop)<\/p>\n<p>plt.ylabel(&#39;Y-axis&#39;, fontproperties=prop)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u5141\u8bb8\u6211\u4eec\u5728\u4e0d\u6539\u53d8\u5168\u5c40\u8bbe\u7f6e\u7684\u60c5\u51b5\u4e0b\uff0c\u4e3a\u7279\u5b9a\u56fe\u5f62\u5143\u7d20\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u5728\u7ed8\u56fe\u51fd\u6570\u4e2d\u76f4\u63a5\u6307\u5b9a\u5b57\u4f53\u53c2\u6570<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u5168\u5c40\u8bbe\u7f6e\u548c\u81ea\u5b9a\u4e49\u5b57\u4f53\u52a0\u8f7d\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728\u7ed8\u56fe\u51fd\u6570\u4e2d\u76f4\u63a5\u6307\u5b9a\u5b57\u4f53\u53c2\u6570\u3002\u6b64\u65b9\u6cd5\u6700\u4e3a\u7075\u6d3b\uff0c\u53ef\u4ee5\u9488\u5bf9\u6bcf\u4e2a\u56fe\u5f62\u5143\u7d20\u5355\u72ec\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4f7f\u7528<code>plt.text()<\/code>\u51fd\u6570\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u6307\u5b9a\u5b57\u4f53\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">plt.text(0.5, 0.5, &#39;Sample Text&#39;, fontsize=14, fontname=&#39;Times New Roman&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7c7b\u4f3c\u5730\uff0c<code>plt.xlabel()<\/code>\u3001<code>plt.ylabel()<\/code>\u3001<code>plt.title()<\/code>\u7b49\u51fd\u6570\u4e5f\u652f\u6301\u76f4\u63a5\u6307\u5b9a\u5b57\u4f53\u53c2\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">plt.xlabel(&#39;X-axis&#39;, fontsize=12, fontname=&#39;Courier New&#39;)<\/p>\n<p>plt.ylabel(&#39;Y-axis&#39;, fontsize=12, fontname=&#39;Courier New&#39;)<\/p>\n<p>plt.title(&#39;My Plot&#39;, fontsize=16, fontname=&#39;Georgia&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u53ef\u4ee5\u8bbe\u7f6e\u5b57\u4f53\u540d\u79f0\u548c\u5927\u5c0f\uff0c\u8fd8\u53ef\u4ee5\u8c03\u6574\u5b57\u4f53\u7684\u5176\u4ed6\u5c5e\u6027\uff0c\u5982\u989c\u8272\u3001\u7c97\u7ec6\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u7ed3\u5408\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\u590d\u6742\u5b57\u4f53\u8bbe\u7f6e<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0\u590d\u6742\u7684\u5b57\u4f53\u8bbe\u7f6e\u3002\u4f8b\u5982\uff0c\u5728\u4e00\u5f20\u56fe\u4e2d\uff0c\u6807\u9898\u3001\u6807\u7b7e\u548c\u6ce8\u91ca\u53ef\u80fd\u9700\u8981\u4e0d\u540c\u7684\u5b57\u4f53\u98ce\u683c\u3002\u8fd9\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u7075\u6d3b\u8fd0\u7528\u524d\u8ff0\u4e09\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u53ef\u4ee5\u4f7f\u7528<code>rcParams<\/code>\u8bbe\u7f6e\u5168\u5c40\u7684\u57fa\u7840\u5b57\u4f53\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u56fe\u5f62\u5143\u7d20\u90fd\u6709\u4e00\u4e2a\u4e00\u81f4\u7684\u9ed8\u8ba4\u98ce\u683c\u3002\u7136\u540e\uff0c\u901a\u8fc7\u5728\u7ed8\u56fe\u51fd\u6570\u4e2d\u76f4\u63a5\u6307\u5b9a\u5b57\u4f53\u53c2\u6570\uff0c\u4e3a\u7279\u5b9a\u5143\u7d20\u8bbe\u7f6e\u4e0d\u540c\u7684\u5b57\u4f53\u98ce\u683c\u3002\u6700\u540e\uff0c\u5982\u679c\u9700\u8981\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\uff0c\u53ef\u4ee5\u5229\u7528<code>font_manager<\/code>\u52a0\u8f7d\u5e76\u5e94\u7528\u4e8e\u7279\u5b9a\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>from matplotlib import font_manager as fm<\/p>\n<h2><strong>\u8bbe\u7f6e\u5168\u5c40\u5b57\u4f53<\/strong><\/h2>\n<p>plt.rcParams[&#39;font.family&#39;] = &#39;sans-serif&#39;<\/p>\n<p>plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;Arial&#39;]<\/p>\n<p>plt.rcParams[&#39;font.size&#39;] = 10<\/p>\n<h2><strong>\u52a0\u8f7d\u81ea\u5b9a\u4e49\u5b57\u4f53<\/strong><\/h2>\n<p>font_path = &#39;\/path\/to\/your\/custom_font.ttf&#39;<\/p>\n<p>custom_font = fm.FontProperties(fname=font_path)<\/p>\n<h2><strong>\u7ed8\u5236\u56fe\u5f62\u5e76\u8bbe\u7f6e\u4e0d\u540c\u5b57\u4f53<\/strong><\/h2>\n<p>plt.figure()<\/p>\n<p>plt.plot([1, 2, 3], [4, 5, 6])<\/p>\n<p>plt.title(&#39;My Custom Plot&#39;, fontsize=14, fontproperties=custom_font)<\/p>\n<p>plt.xlabel(&#39;X-axis&#39;, fontsize=12, fontname=&#39;Times New Roman&#39;)<\/p>\n<p>plt.ylabel(&#39;Y-axis&#39;, fontsize=12, fontname=&#39;Courier New&#39;)<\/p>\n<h2><strong>\u6dfb\u52a0\u6ce8\u91ca<\/strong><\/h2>\n<p>plt.text(2, 5, &#39;Annotation&#39;, fontsize=10, fontname=&#39;Georgia&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u7ec4\u5408\u4f7f\u7528\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u7075\u6d3b\u5730\u8c03\u6574\u56fe\u5f62\u4e2d\u5404\u4e2a\u5143\u7d20\u7684\u5b57\u4f53\u98ce\u683c\uff0c\u5b9e\u73b0\u7f8e\u89c2\u4e14\u7b26\u5408\u9700\u6c42\u7684\u56fe\u5f62\u5c55\u793a\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u5b57\u4f53\u8c03\u6574\u7684\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<p><p>\u5728\u8c03\u6574\u5b57\u4f53\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff0c\u4ee5\u907f\u514d\u5e38\u89c1\u7684\u95ee\u9898\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u517c\u5bb9\u6027\u95ee\u9898<\/strong>\uff1a\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u548c\u73af\u5883\u53ef\u80fd\u5bf9\u5b57\u4f53\u652f\u6301\u6709\u6240\u4e0d\u540c\u3002\u786e\u4fdd\u4f7f\u7528\u7684\u5b57\u4f53\u5728\u76ee\u6807\u73af\u5883\u4e2d\u53ef\u7528\u3002\u5982\u679c\u9700\u8981\u8de8\u5e73\u53f0\u4f7f\u7528\uff0c\u5c3d\u91cf\u9009\u62e9\u901a\u7528\u5b57\u4f53\u6216\u5c06\u81ea\u5b9a\u4e49\u5b57\u4f53\u6587\u4ef6\u968f\u9879\u76ee\u4e00\u8d77\u5206\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b57\u4f53\u5927\u5c0f\u548c\u5e03\u5c40<\/strong>\uff1a\u8c03\u6574\u5b57\u4f53\u5927\u5c0f\u53ef\u80fd\u4f1a\u5f71\u54cd\u56fe\u5f62\u7684\u5e03\u5c40\u3002\u8fc7\u5927\u7684\u5b57\u4f53\u53ef\u80fd\u5bfc\u81f4\u6807\u7b7e\u91cd\u53e0\u6216\u56fe\u5f62\u5143\u7d20\u6324\u5728\u4e00\u8d77\uff0c\u56e0\u6b64\u5728\u8bbe\u7f6e\u5b57\u4f53\u5927\u5c0f\u65f6\uff0c\u8981\u6ce8\u610f\u4e0e\u6574\u4f53\u5e03\u5c40\u7684\u534f\u8c03\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u53ef\u8bfb\u6027<\/strong>\uff1a\u9009\u62e9\u5b57\u4f53\u65f6\u8981\u786e\u4fdd\u53ef\u8bfb\u6027\uff0c\u5c24\u5176\u662f\u5728\u56fe\u5f62\u4e2d\u5305\u542b\u5927\u91cf\u6587\u672c\u65f6\u3002\u8fc7\u4e8e\u82b1\u54e8\u6216\u4e0d\u5e38\u89c1\u7684\u5b57\u4f53\u53ef\u80fd\u5f71\u54cd\u89c2\u4f17\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e00\u81f4\u6027<\/strong>\uff1a\u5728\u4e00\u4efd\u62a5\u544a\u6216\u5c55\u793a\u4e2d\uff0c\u5c3d\u91cf\u4fdd\u6301\u5b57\u4f53\u7684\u4e00\u81f4\u6027\uff0c\u4ee5\u63d0\u9ad8\u4e13\u4e1a\u6027\u548c\u7f8e\u89c2\u5ea6\u3002\u867d\u7136\u6709\u65f6\u9700\u8981\u4e0d\u540c\u5b57\u4f53\u6765\u7a81\u51fa\u91cd\u70b9\uff0c\u4f46\u6574\u4f53\u98ce\u683c\u5e94\u4fdd\u6301\u7edf\u4e00\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u5bf9\u5b57\u4f53\u7684\u7075\u6d3b\u8c03\u6574\uff0c\u6211\u4eec\u53ef\u4ee5\u63d0\u5347\u56fe\u5f62\u7684\u89c6\u89c9\u6548\u679c\uff0c\u4f7f\u5176\u66f4\u52a0\u4e13\u4e1a\u548c\u7f8e\u89c2\u3002\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u540e\uff0c\u60a8\u5c06\u80fd\u591f\u5728Python\u4e2d\u521b\u5efa\u51fa\u8272\u7684\u56fe\u5f62\u5c55\u793a\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bbe\u7f6e\u7ed8\u56fe\u7684\u5b57\u4f53\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Matplotlib\u5e93\u6765\u7ed8\u5236\u56fe\u5f62\u5e76\u8bbe\u7f6e\u5b57\u4f53\u3002\u901a\u8fc7<code>fontdict<\/code>\u53c2\u6570\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u5728\u7ed8\u5236\u51fd\u6570\u4e2d\u6307\u5b9a\u5b57\u4f53\u5c5e\u6027\uff0c\u6216\u8005\u4f7f\u7528<code>plt.rcParams<\/code>\u5168\u5c40\u8bbe\u7f6e\u5b57\u4f53\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u8bbe\u7f6e<code>plt.rcParams[&#39;font.family&#39;]<\/code>\u6765\u6539\u53d8\u6574\u4f53\u5b57\u4f53\uff0c\u6216\u8005\u5728\u7ed8\u5236\u65f6\u4f7f\u7528<code>plt.title(&#39;\u6807\u9898&#39;, fontdict={&#39;fontsize&#39;: 14, &#39;fontweight&#39;: &#39;bold&#39;})<\/code>\u6765\u5355\u72ec\u8bbe\u7f6e\u6807\u9898\u7684\u5b57\u4f53\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u5728Python\u7ed8\u56fe\u4e2d\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u60a8\u53ef\u4ee5\u5728Python\u7ed8\u56fe\u4e2d\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\u3002\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u5df2\u5b89\u88c5\u6240\u9700\u7684\u5b57\u4f53\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u8def\u5f84\u6dfb\u52a0\u5230Matplotlib\u7684\u5b57\u4f53\u7ba1\u7406\u5668\u4e2d\u3002\u53ef\u4ee5\u4f7f\u7528<code>matplotlib.font_manager<\/code>\u6a21\u5757\u6765\u52a0\u8f7d\u548c\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\u3002\u4f7f\u7528<code>font_manager.FontProperties()<\/code>\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5b57\u4f53\u5c5e\u6027\u5bf9\u8c61\uff0c\u5c06\u5176\u4f20\u9012\u7ed9\u7ed8\u56fe\u51fd\u6570\u5373\u53ef\u3002<\/p>\n<p><strong>\u5982\u4f55\u8c03\u6574Python\u7ed8\u56fe\u4e2d\u6807\u7b7e\u548c\u6807\u9898\u7684\u5b57\u4f53\u5927\u5c0f\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u7ed8\u56fe\u51fd\u6570\u4e2d\u8bbe\u7f6e<code>fontsize<\/code>\u53c2\u6570\u6765\u8c03\u6574\u6807\u7b7e\u548c\u6807\u9898\u7684\u5b57\u4f53\u5927\u5c0f\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>plt.xlabel(&#39;X\u8f74&#39;, fontsize=12)<\/code>\u548c<code>plt.ylabel(&#39;Y\u8f74&#39;, fontsize=12)<\/code>\u53ef\u4ee5\u5206\u522b\u8bbe\u7f6eX\u8f74\u548cY\u8f74\u6807\u7b7e\u7684\u5b57\u4f53\u5927\u5c0f\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>plt.title(&#39;\u56fe\u8868\u6807\u9898&#39;, fontsize=16)<\/code>\u53ef\u4ee5\u6539\u53d8\u56fe\u8868\u6807\u9898\u7684\u5b57\u4f53\u5927\u5c0f\uff0c\u4ee5\u786e\u4fdd\u4fe1\u606f\u6e05\u6670\u6613\u8bfb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5f00\u5934\u6bb5\u843d\uff1a\u5728Python\u4e2d\u7ed8\u5236\u56fe\u5f62\u65f6\uff0c\u4fee\u6539\u5b57\u4f53\u7684\u65b9\u5f0f\u5305\u62ec\u4f7f\u7528matplotlib\u5e93\u8bbe\u7f6e\u5b57\u4f53\u5c5e\u6027\u3001\u5229\u7528\u5b57\u4f53\u7ba1\u7406\u5668 [&hellip;]","protected":false},"author":3,"featured_media":965846,"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\/965834"}],"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=965834"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/965834\/revisions"}],"predecessor-version":[{"id":965848,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/965834\/revisions\/965848"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/965846"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=965834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=965834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=965834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}