{"id":2925,"date":"2025-03-18T00:43:20","date_gmt":"2025-03-17T16:43:20","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=2925"},"modified":"2025-03-18T00:43:20","modified_gmt":"2025-03-17T16:43:20","slug":"python-pyecharts-%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/03\/18\/python-pyecharts-%e6%a8%a1%e5%9d%97\/","title":{"rendered":"Python pyecharts \u6a21\u5757"},"content":{"rendered":"\n<p><code>pyecharts<\/code> \u662f\u4e00\u4e2a\u7528\u4e8e\u751f\u6210\u4ea4\u4e92\u5f0f\u56fe\u8868\u7684 Python \u5e93\uff0c\u57fa\u4e8e <code>echarts<\/code>\uff0c\u5b83\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u524d\u7aef\u53ef\u89c6\u5316\u5e93\u3002<code>pyecharts<\/code> \u63d0\u4f9b\u4e86 Python \u63a5\u53e3\uff0c\u4f7f\u5f97\u5728 Python \u4e2d\u521b\u5efa\u9ad8\u8d28\u91cf\u7684\u53ef\u89c6\u5316\u56fe\u8868\u53d8\u5f97\u975e\u5e38\u7b80\u5355\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. <strong><code>pyecharts<\/code> \u7b80\u4ecb<\/strong><\/h2>\n\n\n\n<p><code>pyecharts<\/code> \u662f Python \u5bf9 <code>echarts<\/code> \u7684\u5c01\u88c5\uff0c<code>echarts<\/code> \u662f\u4e00\u4e2a\u57fa\u4e8e JavaScript \u7684\u56fe\u8868\u5e93\uff0c\u652f\u6301\u591a\u79cd\u56fe\u8868\u7c7b\u578b\uff0c\u5982\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u3001\u997c\u56fe\u3001\u6563\u70b9\u56fe\u7b49\uff0c\u5e76\u652f\u6301\u4e30\u5bcc\u7684\u4ea4\u4e92\u64cd\u4f5c\u3001\u52a8\u753b\u6548\u679c\u548c\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>\u5728 <code>pyecharts<\/code> \u4e2d\uff0c\u7528\u6237\u53ea\u9700\u8981\u7b80\u5355\u7684 Python \u4ee3\u7801\uff0c\u5c31\u80fd\u591f\u751f\u6210\u5404\u79cd\u56fe\u8868\uff0c\u5e76\u4e14\u8fd9\u4e9b\u56fe\u8868\u53ef\u4ee5\u4ee5 HTML \u683c\u5f0f\u5bfc\u51fa\uff0c\u5e76\u5728\u7f51\u9875\u4e0a\u8fdb\u884c\u5c55\u793a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. <strong>\u5b89\u88c5 <code>pyecharts<\/code><\/strong><\/h2>\n\n\n\n<p>\u5728\u4f7f\u7528 <code>pyecharts<\/code> \u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u5b83\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>pip<\/code> \u6765\u5b89\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install pyecharts<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. <strong><code>pyecharts<\/code> \u5e38\u7528\u56fe\u8868\u7c7b\u578b<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">3.1 <strong>\u6298\u7ebf\u56fe\uff08Line Chart\uff09<\/strong><\/h3>\n\n\n\n<p>\u6298\u7ebf\u56fe\u7528\u4e8e\u663e\u793a\u6570\u636e\u7684\u53d8\u5316\u8d8b\u52bf\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Line\n\nline = Line(\"\u6298\u7ebf\u56fe\u793a\u4f8b\")\nline.add(\"\u9500\u91cf\", &#91;\"\u4e00\u6708\", \"\u4e8c\u6708\", \"\u4e09\u6708\", \"\u56db\u6708\", \"\u4e94\u6708\"], &#91;10, 20, 30, 40, 50])\nline.render(\"line_chart.html\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.2 <strong>\u67f1\u72b6\u56fe\uff08Bar Chart\uff09<\/strong><\/h3>\n\n\n\n<p>\u67f1\u72b6\u56fe\u7528\u4e8e\u5c55\u793a\u4e0d\u540c\u7c7b\u522b\u7684\u6bd4\u8f83\u6570\u636e\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Bar\n\nbar = Bar(\"\u67f1\u72b6\u56fe\u793a\u4f8b\")\nbar.add(\"\u4ea7\u54c1\u9500\u91cf\", &#91;\"A\", \"B\", \"C\", \"D\"], &#91;40, 60, 80, 100])\nbar.render(\"bar_chart.html\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.3 <strong>\u997c\u56fe\uff08Pie Chart\uff09<\/strong><\/h3>\n\n\n\n<p>\u997c\u56fe\u7528\u4e8e\u5c55\u793a\u4e0d\u540c\u7c7b\u522b\u5728\u6574\u4f53\u4e2d\u6240\u5360\u7684\u6bd4\u4f8b\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Pie\n\npie = Pie(\"\u997c\u56fe\u793a\u4f8b\")\npie.add(\"\u5e02\u573a\u4efd\u989d\", &#91;\"\u82f9\u679c\", \"\u4e09\u661f\", \"\u534e\u4e3a\", \"\u5c0f\u7c73\"], &#91;40, 30, 20, 10])\npie.render(\"pie_chart.html\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.4 <strong>\u6563\u70b9\u56fe\uff08Scatter Chart\uff09<\/strong><\/h3>\n\n\n\n<p>\u6563\u70b9\u56fe\u7528\u4e8e\u5c55\u793a\u4e24\u4e2a\u53d8\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u7279\u522b\u9002\u7528\u4e8e\u663e\u793a\u5206\u5e03\u60c5\u51b5\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Scatter\n\nscatter = Scatter(\"\u6563\u70b9\u56fe\u793a\u4f8b\")\nscatter.add(\"\u5206\u5e03\", &#91;1, 2, 3, 4], &#91;10, 20, 30, 40])\nscatter.render(\"scatter_chart.html\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.5 <strong>\u96f7\u8fbe\u56fe\uff08Radar Chart\uff09<\/strong><\/h3>\n\n\n\n<p>\u96f7\u8fbe\u56fe\u7528\u4e8e\u5c55\u793a\u591a\u7ef4\u5ea6\u6570\u636e\u7684\u60c5\u51b5\uff0c\u5e38\u7528\u4e8e\u5206\u6790\u4e00\u7ec4\u6570\u503c\u5728\u591a\u4e2a\u7ef4\u5ea6\u4e0a\u7684\u8868\u73b0\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Radar\n\nradar = Radar(\"\u96f7\u8fbe\u56fe\u793a\u4f8b\")\nradar.add(\"\u6570\u636e\", &#91;&#91;\"A\", \"B\", \"C\", \"D\", \"E\"]], &#91;10, 20, 30, 40, 50])\nradar.render(\"radar_chart.html\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.6 <strong>\u7bb1\u7ebf\u56fe\uff08Box Plot\uff09<\/strong><\/h3>\n\n\n\n<p>\u7bb1\u7ebf\u56fe\u7528\u4e8e\u5c55\u793a\u6570\u636e\u5206\u5e03\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u9002\u5408\u663e\u793a\u6570\u636e\u7684\u4e2d\u4f4d\u6570\u3001\u4e0a\u4e0b\u56db\u5206\u4f4d\u6570\u7b49\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Boxplot\n\nboxplot = Boxplot(\"\u7bb1\u7ebf\u56fe\u793a\u4f8b\")\nboxplot.add(\"\u6570\u636e\", &#91;&#91;1, 3, 6, 10, 20, 23, 33]])\nboxplot.render(\"boxplot_chart.html\")<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. <strong><code>pyecharts<\/code> \u7684\u9ad8\u7ea7\u529f\u80fd<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">4.1 <strong>\u81ea\u5b9a\u4e49\u6837\u5f0f\u548c\u4e3b\u9898<\/strong><\/h3>\n\n\n\n<p><code>pyecharts<\/code> \u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49\u56fe\u8868\u7684\u6837\u5f0f\uff0c\u5305\u62ec\u989c\u8272\u3001\u5b57\u4f53\u3001\u8fb9\u6846\u7b49\uff0c\u8fd8\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u5185\u7f6e\u7684\u4e3b\u9898\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Bar\n\nbar = Bar(\"\u81ea\u5b9a\u4e49\u4e3b\u9898\u7684\u67f1\u72b6\u56fe\")\nbar.add(\"\u9500\u91cf\", &#91;\"\u82f9\u679c\", \"\u4e09\u661f\", \"\u534e\u4e3a\"], &#91;30, 50, 70], is_label_show=True)\nbar.use_theme(\"dark\")  # \u4f7f\u7528\u5185\u7f6e\u6697\u8272\u4e3b\u9898\nbar.render(\"bar_chart_with_theme.html\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.2 <strong>\u4ea4\u4e92\u529f\u80fd<\/strong><\/h3>\n\n\n\n<p><code>pyecharts<\/code> \u652f\u6301\u4ea4\u4e92\u529f\u80fd\uff0c\u5982\u9f20\u6807\u60ac\u505c\u3001\u70b9\u51fb\u4e8b\u4ef6\u7b49\uff0c\u53ef\u4ee5\u5728\u56fe\u8868\u4e0a\u5b9e\u73b0\u52a8\u6001\u4ea4\u4e92\u6548\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Bar\n\nbar = Bar(\"\u4ea4\u4e92\u5f0f\u67f1\u72b6\u56fe\")\nbar.add(\"\u9500\u91cf\", &#91;\"\u4e00\u6708\", \"\u4e8c\u6708\", \"\u4e09\u6708\", \"\u56db\u6708\", \"\u4e94\u6708\"], &#91;10, 20, 30, 40, 50], is_toolbox_show=True)\nbar.render(\"interactive_bar_chart.html\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.3 <strong>\u56fe\u8868\u7ec4\u5408<\/strong><\/h3>\n\n\n\n<p><code>pyecharts<\/code> \u652f\u6301\u5c06\u591a\u4e2a\u56fe\u8868\u7ec4\u5408\u5728\u540c\u4e00\u9875\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u5c06\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u3001\u997c\u56fe\u7b49\u7ec4\u5408\u6210\u4e00\u4e2a\u56fe\u8868\u5e03\u5c40\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyecharts import Page, Line, Bar\n\nline = Line(\"\u6298\u7ebf\u56fe\")\nline.add(\"\u9500\u91cf\", &#91;\"\u4e00\u6708\", \"\u4e8c\u6708\", \"\u4e09\u6708\", \"\u56db\u6708\"], &#91;10, 20, 30, 40])\n\nbar = Bar(\"\u67f1\u72b6\u56fe\")\nbar.add(\"\u9500\u91cf\", &#91;\"\u4e00\u6708\", \"\u4e8c\u6708\", \"\u4e09\u6708\", \"\u56db\u6708\"], &#91;15, 25, 35, 45])\n\npage = Page()\npage.add(line)\npage.add(bar)\npage.render(\"multiple_charts.html\")<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5. <strong>\u5bfc\u51fa\u56fe\u8868\u4e3a HTML \u6587\u4ef6<\/strong><\/h2>\n\n\n\n<p><code>pyecharts<\/code> \u521b\u5efa\u7684\u56fe\u8868\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5bfc\u51fa\u4e3a HTML \u6587\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u5c06 HTML \u6587\u4ef6\u5d4c\u5165\u5230\u7f51\u9875\u4e2d\uff0c\u6216\u8005\u76f4\u63a5\u901a\u8fc7\u6d4f\u89c8\u5668\u67e5\u770b\u56fe\u8868\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bar.render(\"bar_chart_output.html\")<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">6. <strong><code>pyecharts<\/code> \u7684\u5176\u4ed6\u529f\u80fd<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5730\u56fe\u53ef\u89c6\u5316<\/strong>\uff1a<code>pyecharts<\/code> \u652f\u6301\u4e2d\u56fd\u5730\u56fe\u548c\u4e16\u754c\u5730\u56fe\uff0c\u53ef\u4ee5\u5c06\u6570\u636e\u53ef\u89c6\u5316\u4e3a\u5730\u56fe\u70ed\u529b\u56fe\u6216\u533a\u57df\u56fe\u3002<\/li>\n\n\n\n<li><strong>\u65f6\u95f4\u5e8f\u5217\u53ef\u89c6\u5316<\/strong>\uff1a<code>pyecharts<\/code> \u652f\u6301\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u53ef\u89c6\u5316\uff0c\u53ef\u4ee5\u5c55\u793a\u80a1\u5e02\u3001\u6c14\u8c61\u7b49\u9886\u57df\u7684\u65f6\u95f4\u53d8\u5316\u6570\u636e\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">7. <strong>\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p><code>pyecharts<\/code> \u662f\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u4e14\u6613\u4e8e\u4f7f\u7528\u7684 Python \u56fe\u8868\u5e93\uff0c\u9002\u7528\u4e8e\u5404\u79cd\u6570\u636e\u53ef\u89c6\u5316\u9700\u6c42\uff0c\u5c24\u5176\u5728\u91d1\u878d\u3001\u5546\u4e1a\u3001\u79d1\u5b66\u7b49\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u901a\u8fc7\u7b80\u5355\u7684\u4ee3\u7801\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u751f\u6210\u5404\u79cd\u4ea4\u4e92\u5f0f\u7684\u9ad8\u8d28\u91cf\u56fe\u8868\uff0c\u5e76\u4ee5 HTML \u683c\u5f0f\u5206\u4eab\u6216\u5d4c\u5165\u5230\u7f51\u9875\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pyecharts \u662f\u4e00\u4e2a\u7528\u4e8e\u751f\u6210\u4ea4\u4e92\u5f0f\u56fe\u8868\u7684 Python \u5e93\uff0c\u57fa\u4e8e echarts\uff0c\u5b83\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u524d\u7aef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2926,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[],"class_list":["post-2925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-3-"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=2925"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2925\/revisions"}],"predecessor-version":[{"id":2927,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2925\/revisions\/2927"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media\/2926"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=2925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=2925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=2925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}