{"id":205921,"date":"2025-06-12T09:01:37","date_gmt":"2025-06-12T01:01:37","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205921\/"},"modified":"2025-06-12T09:01:37","modified_gmt":"2025-06-12T01:01:37","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-golang-%e5%87%bd%e6%95%b0%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e5%8f%af%e8%a7%86%e5%8c%96%e5%92%8c%e5%9b%be%e8%a1%a8%e5%8c%96%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205921\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Golang \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f"},"content":{"rendered":"<p>\u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u52aa\u529b\u5b66\u4e60\u5427\uff01\u672c\u6587<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f\u300b<\/span>\u4e3b\u8981\u8bb2\u89e3\u4e86<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6211\u4f1a\u5728GOLANG\u4e2d\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u7684\u7cfb\u5217\u6587\u7ae0\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u5e76\u79ef\u6781\u7559\u8a00\u5efa\u8bae\u3002\u4e0b\u9762\u5c31\u5148\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u672c\u7bc7\u6b63\u6587\u5185\u5bb9\u5427\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01,\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1a\u5bfc\u5165 Plotly \u5e93\u3002\u521b\u5efa\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\u3002\u4f7f\u7528 plotly.NewScatter \u51fd\u6570\u521b\u5efa\u6298\u7ebf\u56fe\u3002\u8bbe\u7f6e\u56fe\u8868\u9009\u9879\uff0c\u5982\u6807\u9898\u3001\u8f74\u6807\u7b7e\u548c\u7f51\u683c\u7ebf\u3002,<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241028\/1730081427671ef29316442.jpg\" class=\"aligncenter\">,<br \/>\n<strong>\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316<\/strong>,<br \/>\n<strong>\u7b80\u4ecb<\/strong>,GOLANG \u7684\u5f3a\u5927\u529f\u80fd\u4f7f\u5176\u6210\u4e3a\u9002\u5408\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\u7684\u8bed\u8a00\u3002\u672c\u6559\u7a0b\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u521b\u5efa\u4ea4\u4e92\u5f0f\u56fe\u8868\u3002,<br \/>\n<strong>\u4f9d\u8d56\u5e93<\/strong>,\u4f60\u5c06\u4f7f\u7528 Plotly \u7684 GOLANG \u5e93\u6765\u751f\u6210\u56fe\u8868\uff1a,<br \/>\n<strong>\u521b\u5efa\u6570\u636e<\/strong>,\u9996\u5148\uff0c\u521b\u5efa\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\uff1a,<br \/>\n<strong>\u521b\u5efa\u6298\u7ebf\u56fe<\/strong>,\u4f7f\u7528<br \/>\n<code>plotly.NewScatter<\/code> \u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u6298\u7ebf\u56fe\uff1a,<br \/>\n<strong>\u8bbe\u7f6e\u56fe\u8868\u9009\u9879<\/strong>,\u8bbe\u7f6e\u56fe\u8868\u9009\u9879\uff0c\u5982\u6807\u9898\u3001\u8f74\u6807\u7b7e\u548c\u7f51\u683c\u7ebf\uff1a,\u672c\u7bc7\u5173\u4e8e\u300a\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8eGOLANG\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\uff01,\u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u52aa\u529b\u5b66\u4e60\u5427\uff01\u672c\u6587<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f\u300b<\/span>\u4e3b\u8981\u8bb2\u89e3\u4e86<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6211\u4f1a\u5728GOLANG\u4e2d\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u7684\u7cfb\u5217\u6587\u7ae0\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u5e76\u79ef\u6781\u7559\u8a00\u5efa\u8bae\u3002\u4e0b\u9762\u5c31\u5148\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u672c\u7bc7\u6b63\u6587\u5185\u5bb9\u5427\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01,<br \/>\n<b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f<\/span><\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f<\/h1>\n<p><span>2024-10-28 10:10:42<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u52aa\u529b\u5b66\u4e60\u5427\uff01\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f\u300b<\/span>\u4e3b\u8981\u8bb2\u89e3\u4e86<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6211\u4f1a\u5728GOLANG\u4e2d\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u7684\u7cfb\u5217\u6587\u7ae0\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u5e76\u79ef\u6781\u7559\u8a00\u5efa\u8bae\u3002\u4e0b\u9762\u5c31\u5148\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u672c\u7bc7\u6b63\u6587\u5185\u5bb9\u5427\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01<\/p>\n<p>\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1a\u5bfc\u5165 Plotly \u5e93\u3002\u521b\u5efa\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\u3002\u4f7f\u7528 plotly.NewScatter \u51fd\u6570\u521b\u5efa\u6298\u7ebf\u56fe\u3002\u8bbe\u7f6e\u56fe\u8868\u9009\u9879\uff0c\u5982\u6807\u9898\u3001\u8f74\u6807\u7b7e\u548c\u7f51\u683c\u7ebf\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241028\/1730081427671ef29316442.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316<\/strong><\/p>\n<p><strong>\u7b80\u4ecb<\/strong><\/p>\n<p>GOLANG \u7684\u5f3a\u5927\u529f\u80fd\u4f7f\u5176\u6210\u4e3a\u9002\u5408\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\u7684\u8bed\u8a00\u3002\u672c\u6559\u7a0b\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u521b\u5efa\u4ea4\u4e92\u5f0f\u56fe\u8868\u3002<\/p>\n<p><strong>\u4f9d\u8d56\u5e93<\/strong><\/p>\n<p>\u4f60\u5c06\u4f7f\u7528 Plotly \u7684 GOLANG \u5e93\u6765\u751f\u6210\u56fe\u8868\uff1a<\/p>\n<pre>import (\n    \"github.com\/plotly\/plotly\"\n    \"github.com\/plotly\/plotly\/plotlyapi\"\n)<\/pre>\n<p><strong>\u521b\u5efa\u6570\u636e<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u521b\u5efa\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\uff1a<\/p>\n<pre>xData := []float64{1, 2, 3, 4}\nyData := []float64{10, 20, 30, 40}<\/pre>\n<p><strong>\u521b\u5efa\u6298\u7ebf\u56fe<\/strong><\/p>\n<p>\u4f7f\u7528 <code>plotly.NewScatter<\/code> \u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u6298\u7ebf\u56fe\uff1a<\/p>\n<pre>trace := plotly.NewScatter(xData, yData)<\/pre>\n<p><strong>\u8bbe\u7f6e\u56fe\u8868\u9009\u9879<\/strong><\/p>\n<p>\u8bbe\u7f6e\u56fe\u8868\u9009\u9879\uff0c\u5982\u6807\u9898\u3001\u8f74\u6807\u7b7e\u548c\u7f51\u683c\u7ebf\uff1a<\/p>\n<pre>layout := plotly.NewLayout()<\/pre>\n<p>\u672c\u7bc7\u5173\u4e8e\u300a\u5982\u4f55\u4f7f\u7528 GOLANG \u51fd\u6570\u5b9e\u73b0\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u8868\u5316\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8eGOLANG\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   CSS \u4e2d\u5982\u4f55\u4f7f\u5bf9\u8c61\u4e3a\u7a7a\u65f6\u7684\u6837\u5f0f\u5931\u6548\uff1f\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u4e2d\u56fd\u79d1\u5b66\u9662\u56e2\u961f\u53d1\u5e03GeneCompass\uff1a\u89e3\u6790\u57fa\u56e0\u8c03\u63a7\u5bc6\u7801\uff0c\u6253\u9020\u5e72\u6e7f\u878d\u5408\u65b0\u8303\u5f0f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u73b0\u5728\u5f00\u59cb\uff0c\u52aa\u529b\u5b66\u4e60\u5427\uff01\u672c\u6587 \u300a&#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-205921","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205921","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=205921"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205921\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}