{"id":21367,"date":"2024-11-19T09:38:22","date_gmt":"2024-11-19T01:38:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21367\/"},"modified":"2024-11-19T09:38:22","modified_gmt":"2024-11-19T01:38:22","slug":"vscode%e6%80%8e%e4%b9%88%e7%94%a8%e5%9b%be%e5%bd%a2%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21367\/","title":{"rendered":"vscode\u600e\u4e48\u7528\u56fe\u5f62\u5e93"},"content":{"rendered":"<blockquote><p>\n  \u5728 vscode \u4e2d\u4f7f\u7528\u56fe\u5f62\u5e93\u5206\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u5b89\u88c5\u56fe\u5f62\u5e93\u6269\u5c55\uff0c\u4f8b\u5982 plotly \u6216 bokeh\u3002\u5728 python \u4ee3\u7801\u4e2d\u5bfc\u5165\u56fe\u5f62\u5e93\uff0c\u4f8b\u5982 import plotly.graph_objects as go\u3002\u521b\u5efa\u6570\u636e\uff0c\u4f8b\u5982\u5217\u8868\u6216\u6570\u7ec4\u3002\u4f7f\u7528\u56fe\u5f62\u5e93\u65b9\u6cd5\u521b\u5efa\u56fe\u5f62\u5bf9\u8c61\uff0c\u4f8b\u5982 go.scatter(x=x_data, y=y_data)\u3002\u4f7f\u7528\u56fe\u5f62\u5e93\u65b9\u6cd5\u663e\u793a\u56fe\u8868\uff0c\u4f8b\u5982 fig.show()\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052712272330716.jpg\" class=\"aligncenter\" title=\"vscode\u600e\u4e48\u7528\u56fe\u5f62\u5e93\u63d2\u56fe\" alt=\"vscode\u600e\u4e48\u7528\u56fe\u5f62\u5e93\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 VSCode \u4e2d\u4f7f\u7528\u56fe\u5f62\u5e93<\/strong><\/p>\n<p><strong>\u5f15\u8a00<\/strong><br \/>VSCode \u662f\u4e00\u6b3e\u6d41\u884c\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u5b83\u652f\u6301\u901a\u8fc7\u5b89\u88c5\u6269\u5c55\u6765\u6269\u5c55\u5176\u529f\u80fd\u3002\u5728 VSCode \u4e2d\u4f7f\u7528\u56fe\u5f62\u5e93\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u8f7b\u677e\u521b\u5efa\u548c\u3002<\/p>\n<p><strong>\u6b65\u9aa4<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u4e00\u4e2a\u56fe\u5f62\u5e93\u6269\u5c55<\/strong><\/p>\n<ul>\n<li>\u6253\u5f00 VSCode\uff0c\u9009\u62e9\u201c\u6269\u5c55\u201d\u9009\u9879\u5361\u3002<\/li>\n<li>\u641c\u7d22\u60a8\u559c\u6b22\u7684\u56fe\u5f62\u5e93\uff0c\u4f8b\u5982\u201cPlotly\u201d\u6216\u201cBokeh\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u6309\u94ae\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5bfc\u5165\u5e93<\/strong><\/p>\n<ul>\n<li>\n<p>\u5728\u60a8\u7684 Python \u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5bfc\u5165\u56fe\u5f62\u5e93\uff1a<\/p>\n<pre>import plotly.graph_objects as go<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong><\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\u51c6\u5907\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\uff0c\u4f8b\u5982\u5217\u8868\u3001\u6570\u7ec4\u6216\u5b57\u5178\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u56fe\u5f62\u5bf9\u8c61<\/strong><\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528\u56fe\u5f62\u5e93\u63d0\u4f9b\u7684\u65b9\u6cd5\u521b\u5efa\u56fe\u5f62\u5bf9\u8c61\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 Plotly \u521b\u5efa\u6298\u7ebf\u56fe\uff1a<\/p>\n<pre>fig = go.Figure()\nfig.add_trace(go.Scatter(x=x_data, y=y_data))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u663e\u793a\u56fe\u8868<\/strong><\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528\u56fe\u5f62\u5e93\u63d0\u4f9b\u7684\u65b9\u6cd5\u5c06\u56fe\u8868\u663e\u793a\u5728 VSCode \u4e2d\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 Plotly\uff1a<\/p>\n<pre>fig.show()<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b<\/strong><br \/>\u4ee5\u4e0b\u4ee3\u7801\u5728 VSCode \u4e2d\u4f7f\u7528 Plotly \u5e93\u7ed8\u5236\u6298\u7ebf\u56fe\uff1a<\/p>\n<pre>import plotly.graph_objects as go\n\n# \u521b\u5efa\u6570\u636e\nx_data = [1, 2, 3, 4, 5]\ny_data = [2, 4, 6, 8, 10]\n\n# \u521b\u5efa\u6298\u7ebf\u56fe\nfig = go.Figure()\nfig.add_trace(go.Scatter(x=x_data, y=y_data))\n\n# \u663e\u793a\u56fe\u8868\nfig.show()<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5176\u4ed6\u56fe\u5f62\u5e93<\/strong><br \/>\u9664 Plotly \u5916\uff0c\u8fd8\u6709\u8bb8\u591a\u5176\u4ed6\u53ef\u7528\u4e8e VSCode \u7684\u56fe\u5f62\u5e93\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>Bokeh<\/li>\n<li>Matplotlib<\/li>\n<li>Seaborn<\/li>\n<li>ggplot<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u7528\u56fe\u5f62\u5e93\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 vscode \u4e2d\u4f7f\u7528\u56fe\u5f62\u5e93\u5206\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u5b89\u88c5\u56fe\u5f62\u5e93\u6269\u5c55\uff0c\u4f8b\u5982 plotly \u6216 bokeh\u3002\u5728 python \u4ee3\u7801\u4e2d\u5bfc\u5165\u56fe\u5f62\u5e93\uff0c\u4f8b\u5982 import plotly.graph_objects as go\u3002\u521b\u5efa\u6570\u636e\uff0c\u4f8b\u5982\u5217\u8868\u6216\u6570\u7ec4\u3002\u4f7f\u7528\u56fe\u5f62\u5e93\u65b9\u6cd5\u521b\u5efa\u56fe\u5f62\u5bf9\u8c61\uff0c\u4f8b\u5982 go.scatter(x=x_data, y=y_data)\u3002\u4f7f\u7528\u56fe\u5f62\u5e93\u65b9\u6cd5\u663e\u793a\u56fe\u8868\uff0c\u4f8b\u5982 fig.show()\u3002 \u5982\u4f55\u5728 VSCode \u4e2d\u4f7f\u7528\u56fe\u5f62\u5e93 \u5f15\u8a00VSCode \u662f\u4e00\u6b3e\u6d41\u884c\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u5b83\u652f\u6301\u901a\u8fc7\u5b89\u88c5\u6269\u5c55\u6765\u6269\u5c55\u5176\u529f\u80fd\u3002\u5728 VSCode \u4e2d\u4f7f\u7528\u56fe\u5f62\u5e93\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u8f7b\u677e\u521b\u5efa\u548c\u3002 \u6b65\u9aa4 \u5b89\u88c5\u4e00\u4e2a\u56fe\u5f62\u5e93\u6269\u5c55 \u6253\u5f00 VSCode\uff0c\u9009\u62e9\u201c\u6269\u5c55\u201d\u9009\u9879\u5361\u3002 \u641c\u7d22\u60a8\u559c\u6b22\u7684\u56fe\u5f62\u5e93\uff0c\u4f8b\u5982\u201cPlotly\u201d\u6216\u201cBokeh\u201d\u3002 \u70b9\u51fb\u201c\u5b89\u88c5\u201d\u6309\u94ae\u3002 \u5bfc\u5165\u5e93 \u5728\u60a8\u7684 Python \u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5bfc\u5165\u56fe\u5f62\u5e93\uff1a import plotly.graph_objects as go \u767b\u5f55\u540e\u590d\u5236 \u521b\u5efa\u6570\u636e \u51c6\u5907\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\uff0c\u4f8b\u5982\u5217\u8868\u3001\u6570\u7ec4\u6216\u5b57\u5178\u3002 \u521b\u5efa\u56fe\u5f62\u5bf9\u8c61 \u4f7f\u7528\u56fe\u5f62\u5e93\u63d0\u4f9b\u7684\u65b9\u6cd5\u521b\u5efa\u56fe\u5f62\u5bf9\u8c61\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 Plotly \u521b\u5efa\u6298\u7ebf\u56fe\uff1a fig = go.Figure() fig.add_trace(go.Scatter(x=x_data, y=y_data)) \u767b\u5f55\u540e\u590d\u5236 \u663e\u793a\u56fe\u8868 \u4f7f\u7528\u56fe\u5f62\u5e93\u63d0\u4f9b\u7684\u65b9\u6cd5\u5c06\u56fe\u8868\u663e\u793a\u5728 VSCode \u4e2d\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 Plotly\uff1a fig.show() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21367","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21367"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21367\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}