{"id":205156,"date":"2025-05-29T11:48:15","date_gmt":"2025-05-29T03:48:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205156\/"},"modified":"2025-05-29T11:48:15","modified_gmt":"2025-05-29T03:48:15","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-matplotlib-%e7%bb%98%e5%88%b6%e5%b8%a6%e6%9c%89%e7%bd%ae%e4%bf%a1%e5%8c%ba%e9%97%b4%e7%9a%84%e5%8f%8c%e6%a0%b8%e5%bf%83%e6%95%a3%e7%82%b9%e5%9b%be%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205156\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Matplotlib \u7ed8\u5236\u5e26\u6709\u7f6e\u4fe1\u533a\u95f4\u7684\u53cc\u6838\u5fc3\u6563\u70b9\u56fe\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 Matplotlib \u7ed8\u5236\u5e26\u6709\u7f6e\u4fe1\u533a\u95f4\u7684\u53cc\u6838\u5fc3\u6563\u70b9\u56fe\uff1f<\/h1>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241124\/1732454679674329179f365.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u5982\u4f55\u7ed8\u5236\u5e26\u6709\u7f6e\u4fe1\u533a\u95f4\u7684\u53cc\u6838\u5fc3\u6563\u70b9\u56fe\uff1f<\/strong><\/p>\n<p>\u60f3\u8981\u7ed8\u5236\u5305\u542b\u7f6e\u4fe1\u533a\u95f4\u7684\u53cc\u6838\u5fc3\u6563\u70b9\u56fe\uff0c\u53ef\u4ee5\u4f7f\u7528 matplotlib \u4e2d\u7684 errorbar \u51fd\u6570\u3002\u8be5\u51fd\u6570\u5141\u8bb8\u60a8\u6307\u5b9a\u4e2d\u5fc3\u70b9\u3001\u8bef\u5dee\u6761\u548c\u7f6e\u4fe1\u533a\u95f4\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li><strong>\u5bfc\u5165 matplotlib\uff1a<\/strong> \u9996\u5148\uff0c\u5bfc\u5165 matplotlib \u5e93\u3002<\/li>\n<li><strong>\u51c6\u5907\u6570\u636e\uff1a<\/strong> \u5c06\u60a8\u7684\u6570\u636e\u6574\u7406\u6210\u4e00\u4e2a\u5305\u542b\u4e09\u5217\u7684\u6570\u7ec4\u3002\u7b2c\u4e00\u5217\u8868\u793a\u6838\u5fc3\u70b9 1\uff0c\u7b2c\u4e8c\u5217\u548c\u7b2c\u4e09\u5217\u5206\u522b\u8868\u793a\u7f6e\u4fe1\u533a\u95f4\u7684\u4e0a\u754c\u548c\u4e0b\u754c\u3002<\/li>\n<li><strong>\u521b\u5efa\u56fe\u5f62\uff1a<\/strong> \u4f7f\u7528 plt.subplots \u51fd\u6570\u521b\u5efa\u56fe\u5f62\u5bf9\u8c61\u3002<\/li>\n<li><strong>\u7ed8\u5236\u6563\u70b9\u56fe\uff1a<\/strong> \u4f7f\u7528 plt.errorbar \u51fd\u6570\u7ed8\u5236\u6563\u70b9\u56fe\u3002\u5bf9\u4e8e\u6bcf\u4e2a\u6838\u5fc3\u70b9\uff0c\u6307\u5b9a\u4e2d\u5fc3\u70b9\u3001\u7f6e\u4fe1\u533a\u95f4\u4e0a\u754c\u548c\u4e0b\u754c\u3002<\/li>\n<li><strong>\u8bbe\u7f6e\u56fe\u4f8b\u548c\u6807\u9898\uff1a<\/strong> \u6dfb\u52a0\u56fe\u4f8b\u548c\u6807\u9898\uff0c\u4ee5\u8868\u793a\u4e0d\u540c\u7684\u6570\u636e\u7ec4\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>import matplotlib.pyplot as plt\n\n# \u51c6\u5907\u6570\u636e\ndata =[['core1', 'up1', 'down1'],\n         ['core1', 'up2', 'down2'],\n         ['core2', 'up3', 'down3']]\n\n# \u521b\u5efa\u56fe\u5f62\nfig, ax = plt.subplots()\n\n# \u7ed8\u5236\u6563\u70b9\u56fe\nax.errorbar([d[0] for d in data], [d[1] for d in data], yerr=[abs(float(d[1])-float(d[2])) for d in data])\n\n# \u8bbe\u7f6e\u56fe\u4f8b\nplt.legend(['Group A', 'Group B', 'Group C'])\n\n# \u8bbe\u7f6e\u6807\u9898\nplt.title('Dual Core Scatter Plot with Confidence Intervals')\n\n# \u663e\u793a\u56fe\u5f62\nplt.show()<\/pre>\n<p>\u5e0c\u671b\u6b64\u89e3\u7b54\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300a\u5982\u4f55\u4f7f\u7528 Matplotlib \u7ed8\u5236\u5e26\u6709\u7f6e\u4fe1\u533a\u95f4\u7684\u53cc\u6838\u5fc3\u6563\u70b9\u56fe\uff1f\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 Matplotlib &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-205156","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=205156"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205156\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}