{"id":86527,"date":"2026-07-28T20:48:24","date_gmt":"2026-07-28T12:48:24","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/86527.html"},"modified":"2026-07-28T20:48:24","modified_gmt":"2026-07-28T12:48:24","slug":"%e4%bd%bf%e7%94%a8-matplotlib-%e7%bb%98%e5%88%b6%e4%b8%89%e7%bb%b4%e6%95%a3%e7%82%b9%e5%9b%be","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/86527.html","title":{"rendered":"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe"},"content":{"rendered":"<h3>\u5206\u7c7b\u5b66\u4e60<\/h3>\n<p>1\u3001\u6570\u636e\u8bfb\u53d6<br \/>\n**\u5b9a\u4e49&#xff1a;**\u6570\u636e\u8bfb\u53d6\u6307\u7684\u662f\u628a\u5916\u90e8\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u52a0\u8f7d\u5230 Python \u4e2d&#xff0c;\u53d8\u6210\u7a0b\u5e8f\u53ef\u4ee5\u5904\u7406\u7684\u6570\u636e\u7ed3\u6784\u3002<br \/>\n&#xff08;1&#xff09;. \u4f7f\u7528 NumPy \u8bfb\u53d6 txt \u6570\u636e<br \/>\nnumpy.loadtxt() \u4f5c\u7528&#xff1a;\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6570\u503c\u6570\u636e&#xff0c;\u5e76\u8f6c\u6362\u6210 NumPy \u6570\u7ec4&#xff08;ndarray&#xff09;<br \/>\n&#xff08;2&#xff09;.\u8bfb\u53d6\u540e\u7684\u6570\u636e\u7ed3\u6784<br \/>\ndata &#061; np.loadtxt(\u2018datingTestSet2.txt\u2019)<br \/>\nprint(data.shape)<br \/>\n\u8f93\u51fa&#xff1a;(1000, 4)<br \/>\n\u8868\u793a1000\u884c \u2192 1000\u4e2a\u6837\u672c<br \/>\n4\u5217 \u2192 4\u4e2a\u6570\u636e\u5b57\u6bb5<br \/>\n&#xff08;3&#xff09;.\u901a\u8fc7\u5207\u7247\u83b7\u53d6\u6570\u636e<br \/>\ndata_1 &#061; data[data[:, -1] ]<br \/>\n\u8fd9\u91cc\u7684data[:,-1]\u8868\u793a\u7684\u662f\u53d6\u6240\u6709\u884c\u7684\u6700\u540e\u4e00\u5217\u3002<br \/>\n2\u3001\u7ed8\u5236\u4e09\u7ef4\u56fe<br \/>\n&#xff08;1&#xff09;. \u521b\u5efa\u7ed8\u56fe\u7a97\u53e3<br \/>\nfig &#061; plt.figure()#figure\u51fd\u6570<br \/>\n&#xff08;2&#xff09;. \u521b\u5efa\u4e09\u7ef4\u5750\u6807\u8f74<br \/>\nax &#061; plt.axes(projection&#061;\u20183d\u2019)#\u521b\u5efa\u4e00\u4e2a 3D\u5750\u6807\u7cfb\u3002<br \/>\n&#xff08;3&#xff09;. \u7ed8\u5236\u7c7b\u522b1\u6570\u636e<br \/>\nscatter() \u662f\u6563\u70b9\u56fe\u51fd\u6570\u3002#\u683c\u5f0f&#xff1a;ax.scatter(x\u5750\u6807, y\u5750\u6807, z\u5750\u6807)<br \/>\nax.scatter(data_1[:,0], data_1[:,1], data_1[:,2], c &#061; \u201c#00DDAA\u201d,marker&#061;\u201co\u201d)<br \/>\ndata_1[:,0]\u8868\u793adata\u7b2c0\u5217\u53d6x<br \/>\ndata_1[:,1]\u8868\u793adata\u7b2c1\u5217\u53d6y<br \/>\ndata_1[:,2]\u8868\u793adata\u7b2c2\u5217\u53d6z<br \/>\n&#034;#00DDAA&#034;\u8868\u793a\u989c\u8272&#xff0c;&#034;o&#034;\u8868\u793a\u5f62\u72b6\u4e3a\u5706\u5f62<br \/>\n&#xff08;4&#xff09;.\u663e\u793a\u56fe\u5f62<br \/>\nplt.show()#\u628a\u7ed8\u5236\u597d\u7684\u56fe\u663e\u793a\u51fa\u6765\u3002<\/p>\n<h3>\u5217\u56fe&#xff1a;<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260728124821-6a68a51564b94.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u7c7b\u5b66\u4e60<br \/>\n1\u3001\u6570\u636e\u8bfb\u53d6<br \/>\n**\u5b9a\u4e49&#xff1a;**\u6570\u636e\u8bfb\u53d6\u6307\u7684\u662f\u628a\u5916\u90e8\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u52a0\u8f7d\u5230 Python \u4e2d&#xff0c;\u53d8\u6210\u7a0b\u5e8f\u53ef\u4ee5\u5904\u7406\u7684\u6570\u636e\u7ed3\u6784\u3002<br \/>\n&#xff08;1&#xff09;. \u4f7f\u7528 NumPy \u8bfb\u53d6 txt \u6570\u636e<br \/>\nnumpy.loadtxt() \u4f5c\u7528&#xff1a;\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6570\u503c\u6570\u636e&#xff0c;\u5e76\u8f6c\u6362\u6210 NumPy \u6570\u7ec4&#xff08;ndarray&#xff09;<br \/>\n&#xff08;2&#xff09;.\u8bfb\u53d6\u540e\u7684\u6570\u636e\u7ed3\u6784<br \/>\ndata  np.loadtx<\/p>\n","protected":false},"author":2,"featured_media":86526,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,190],"topic":[],"class_list":["post-86527","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-python","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/86527.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5206\u7c7b\u5b66\u4e60 1\u3001\u6570\u636e\u8bfb\u53d6 **\u5b9a\u4e49&#xff1a;**\u6570\u636e\u8bfb\u53d6\u6307\u7684\u662f\u628a\u5916\u90e8\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u52a0\u8f7d\u5230 Python \u4e2d&#xff0c;\u53d8\u6210\u7a0b\u5e8f\u53ef\u4ee5\u5904\u7406\u7684\u6570\u636e\u7ed3\u6784\u3002 &#xff08;1&#xff09;. \u4f7f\u7528 NumPy \u8bfb\u53d6 txt \u6570\u636e numpy.loadtxt() \u4f5c\u7528&#xff1a;\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6570\u503c\u6570\u636e&#xff0c;\u5e76\u8f6c\u6362\u6210 NumPy \u6570\u7ec4&#xff08;ndarray&#xff09; &#xff08;2&#xff09;.\u8bfb\u53d6\u540e\u7684\u6570\u636e\u7ed3\u6784 data np.loadtx\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/86527.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-28T12:48:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260728124821-6a68a51564b94.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/86527.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/86527.html\",\"name\":\"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-28T12:48:24+00:00\",\"dateModified\":\"2026-07-28T12:48:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/86527.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/86527.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/86527.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/86527.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5206\u7c7b\u5b66\u4e60 1\u3001\u6570\u636e\u8bfb\u53d6 **\u5b9a\u4e49&#xff1a;**\u6570\u636e\u8bfb\u53d6\u6307\u7684\u662f\u628a\u5916\u90e8\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u52a0\u8f7d\u5230 Python \u4e2d&#xff0c;\u53d8\u6210\u7a0b\u5e8f\u53ef\u4ee5\u5904\u7406\u7684\u6570\u636e\u7ed3\u6784\u3002 &#xff08;1&#xff09;. \u4f7f\u7528 NumPy \u8bfb\u53d6 txt \u6570\u636e numpy.loadtxt() \u4f5c\u7528&#xff1a;\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6570\u503c\u6570\u636e&#xff0c;\u5e76\u8f6c\u6362\u6210 NumPy \u6570\u7ec4&#xff08;ndarray&#xff09; &#xff08;2&#xff09;.\u8bfb\u53d6\u540e\u7684\u6570\u636e\u7ed3\u6784 data np.loadtx","og_url":"https:\/\/www.wsisp.com\/helps\/86527.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-28T12:48:24+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260728124821-6a68a51564b94.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/86527.html","url":"https:\/\/www.wsisp.com\/helps\/86527.html","name":"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-28T12:48:24+00:00","dateModified":"2026-07-28T12:48:24+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/86527.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/86527.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/86527.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528 Matplotlib \u7ed8\u5236\u4e09\u7ef4\u6563\u70b9\u56fe"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/86527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=86527"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/86527\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/86526"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=86527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=86527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=86527"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=86527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}