﻿{"id":1633,"date":"2020-08-01T19:07:44","date_gmt":"2020-08-01T11:07:44","guid":{"rendered":"https:\/\/www.linuxmi.com\/?p=1633"},"modified":"2020-08-02T08:00:48","modified_gmt":"2020-08-02T00:00:48","slug":"matplotlib-yangshi","status":"publish","type":"post","link":"https:\/\/www.linuxmi.com\/matplotlib-yangshi.html","title":{"rendered":"Python Matplotlib \u6559\u7a0b\uff1a\u5982\u4f55\u63a7\u5236Matplotlib\u6837\u5f0f"},"content":{"rendered":"<p>\u5728\u672c\u7bc7Python Matplotlib \u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u63a7\u5236Matplotlib\u6837\u5f0f\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u5728\u4e09\u4e2a\u90e8\u5206\u81ea\u5b9a\u4e49Matplotlib\u6837\u5f0f\uff1a\u60a8\u53ef\u4ee5\u5b9a\u5236\u989c\u8272\u3001\u7ebf\u6761\u6837\u5f0f\u548c\u6807\u8bb0\u6837\u5f0f\u3002<\/p>\n<p><strong>\u63a7\u5236\u989c\u8272<\/strong><\/p>\n<p>\u6709\u65f6\u5728\u7ed8\u56fe\u65f6\uff0c\u60a8\u5e0c\u671b\u81ea\u5b9a\u4e49Matplotlib\u56fe\u5f62\u7684\u989c\u8272\uff0c\u5e0c\u671b\u63a7\u5236Matplotlib\u6837\u5f0f\uff0c\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5728\u7ed8\u5236\u7ebf\u6761\uff0c\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u7ebf\u6761\u5b9a\u5236\u989c\u8272\u3002<\/p>\n<pre style=\"font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px; line-height: 1.2em;\"><code style=\"font-size: 0.85em; overflow: auto; font-family: Consolas, Inconsolata, Courier, monospace; background: #292824; white-space: pre; overflow-x: auto; color: #a6a28c; margin: 0px 0.15em; display: block; border-radius: 3px; -moz-text-size-adjust: none; border: #cccccc 1px solid; padding: 0.5em;\"><span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">import<\/span><\/span> matplotlib.pyplot <span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">as<\/span><\/span> plt\r\n<span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">import<\/span><\/span> numpy <span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">as<\/span><\/span> np\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u6211\u4eec\u7684\u6570\u636e<\/span><\/span>\r\nx = np.array([<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">1<\/span><\/span>,<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">2<\/span><\/span>,<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">3<\/span><\/span>])\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u7528\u4e09\u79cd\u989c\u8272\u7ed8\u5236\u4e09\u884c<\/span><\/span>\r\nplt.plot(x, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'y'<\/span><\/span>)\r\nplt.plot(x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">1<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'m'<\/span><\/span>)\r\nplt.plot(x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">2<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'c'<\/span><\/span>)\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u663e\u793a\u56fe\u5f62<\/span><\/span>\r\nplt.show()\r\n<\/code><\/pre>\n<p>\u4f60\u53ef\u4ee5\u770b\u5230\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u4e3a\u6211\u4eec\u7684\u884c\u6307\u5b9a\u4e86\u989c\u8272\u3002<\/p>\n<p>\u5982\u679c\u60a8\u8fd0\u884c\u8be5\u4ee3\u7801\uff0c\u7ed3\u679c\u5c06\u662f\u8fd9\u6837\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1635\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-1.png\" alt=\"\" width=\"833\" height=\"690\" srcset=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-1.png 833w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-1-300x248.png 300w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-1-768x636.png 768w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-1-423x350.png 423w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/p>\n<p>Matplotlib\u4e2d\u6709\u4e0d\u540c\u7684\u989c\u8272\uff0c\u4e0b\u9762\u662fMatplotlib\u989c\u8272\u8868\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>\u989c\u8272<\/strong><\/td>\n<td><strong>\u989c\u8272\u540d\u79f0<\/strong><\/td>\n<\/tr>\n<tr>\n<td>b<\/td>\n<td>blue<\/td>\n<\/tr>\n<tr>\n<td>c<\/td>\n<td>cyan<\/td>\n<\/tr>\n<tr>\n<td>g<\/td>\n<td>green<\/td>\n<\/tr>\n<tr>\n<td>k<\/td>\n<td>black<\/td>\n<\/tr>\n<tr>\n<td>m<\/td>\n<td>magenta<\/td>\n<\/tr>\n<tr>\n<td>r<\/td>\n<td>red<\/td>\n<\/tr>\n<tr>\n<td>w<\/td>\n<td>white<\/td>\n<\/tr>\n<tr>\n<td>y<\/td>\n<td>yellow<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u63a7\u5236\u7ebf\u6761\u6837\u5f0f<\/strong><\/p>\n<p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\u6211\u4eec\u770b\u5230\u7684\u7ebf\u6761\uff0c\u53ea\u662f\u6ca1\u6709\u4efb\u4f55\u70b9\u6216\u7834\u6298\u53f7\u7684\u7ebf\u6761\uff0c\u5728Matplotlib\u4e2d\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u7ebf\u6761\u6837\u5f0f\u3002<\/p>\n<pre style=\"font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px; line-height: 1.2em;\"><code style=\"font-size: 0.85em; overflow: auto; font-family: Consolas, Inconsolata, Courier, monospace; background: #292824; white-space: pre; overflow-x: auto; color: #a6a28c; margin: 0px 0.15em; display: block; border-radius: 3px; -moz-text-size-adjust: none; border: #cccccc 1px solid; padding: 0.5em;\"><span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">import<\/span><\/span> matplotlib.pyplot <span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">as<\/span><\/span> plt\r\n<span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">import<\/span><\/span> numpy <span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">as<\/span><\/span> np\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u6211\u4eec\u7684\u6570\u636e<\/span><\/span>\r\nx = np.array([<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">1<\/span><\/span>,<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">2<\/span><\/span>,<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">3<\/span><\/span>])\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u7528\u4e09\u79cd\u989c\u8272\u7ed8\u5236\u4e09\u884c<\/span><\/span>\r\nplt.plot(x, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'--'<\/span><\/span>, x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">1<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'-.'<\/span><\/span>, x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">2<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">':'<\/span><\/span>,x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">3<\/span><\/span>,<span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'-'<\/span><\/span>)\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u663e\u793a\u56fe\u5f62<\/span><\/span>\r\nplt.show()<\/code><\/pre>\n<p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u5728plot\u51fd\u6570\u4e2d\u6211\u4eec\u4f7f\u7528\u4e86\u7ebf\u6761\u3002<\/p>\n<p>\u5982\u679c\u60a8\u8fd0\u884c\u5b8c\u6574\u7684\u4ee3\u7801\uff0c\u7ed3\u679c\u5982\u4e0b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1636\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-2.png\" alt=\"\" width=\"731\" height=\"635\" srcset=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-2.png 887w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-2-300x260.png 300w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-2-768x667.png 768w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-2-403x350.png 403w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<p>Matplotlib\u4e2d\u6709\u4e0d\u540c\u7684\u7ebf\u6761\uff0c\u4ee5\u4e0b\u662fMatplotlib\u7ebf\u6761\u8868\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>\u6837\u5f0f\u7f29\u5199 <\/strong><\/td>\n<td><strong>\u6837\u5f0f<br \/>\n<\/strong><\/td>\n<\/tr>\n<tr>\n<td>\u2013<\/td>\n<td>\u5b9e\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>\u2014<\/td>\n<td>\u865a\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>-.<\/td>\n<td>\u70b9\u5212\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>:<\/td>\n<td>\u70b9\u7ebf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u63a7\u5236\u6807\u8bb0\u6837\u5f0f<\/strong><\/p>\n<p>Matplotlib\u4e3a\u6807\u8bb0\u63d0\u4f9b\u4e86\u8bb8\u591a\u81ea\u5b9a\u4e49\u9009\u9879\u3002<\/p>\n<pre style=\"font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px; line-height: 1.2em;\"><code style=\"font-size: 0.85em; overflow: auto; font-family: Consolas, Inconsolata, Courier, monospace; background: #292824; white-space: pre; overflow-x: auto; color: #a6a28c; margin: 0px 0.15em; display: block; border-radius: 3px; -moz-text-size-adjust: none; border: #cccccc 1px solid; padding: 0.5em;\"><span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">import<\/span><\/span> matplotlib.pyplot <span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">as<\/span><\/span> plt\r\n<span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">import<\/span><\/span> numpy <span style=\"color: #b854d4;\"><span style=\"background-color: #292824;\">as<\/span><\/span> np\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u6211\u4eec\u7684\u6570\u636e<\/span><\/span>\r\nx = np.array([<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">1<\/span><\/span>,<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">2<\/span><\/span>,<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">3<\/span><\/span>])\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u7ed8\u56fe\u6807\u8bb0<\/span><\/span>\r\nplt.plot(x, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'x'<\/span><\/span>, x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">0.7<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'o'<\/span><\/span>, x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">1<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'D'<\/span><\/span>, x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">1.5<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'^'<\/span><\/span>, x+<span style=\"color: #b65611;\"><span style=\"background-color: #292824;\">2<\/span><\/span>, <span style=\"color: #60ac39;\"><span style=\"background-color: #292824;\">'s'<\/span><\/span>)\r\n\r\n<span style=\"color: #999580;\"><span style=\"background-color: #292824;\">#\u663e\u793a\u56fe\u5f62<\/span><\/span>\r\nplt.show()\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8fd0\u884c\u4ee3\u7801\uff0c\u5219\u5c06\u5f97\u5230\u5982\u4e0b\u7ed3\u679c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1637\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-3.png\" alt=\"\" width=\"731\" height=\"652\" srcset=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-3.png 874w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-3-300x268.png 300w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-3-768x685.png 768w, https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/08\/Matplotlib-3-392x350.png 392w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<p>\u60a8\u53ef\u4ee5\u5728Matplotlib\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684\u6807\u8bb0\u6837\u5f0f\uff0c\u6211\u4eec\u5728\u6b64\u8868\u4e2d\u4ec5\u5217\u4e3e\u4e86\u5176\u4e2d\u4e00\u4e9b\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>\u6807\u8bb0\u7f29\u5199<\/strong><\/td>\n<td><strong>\u6807\u8bb0\u6837\u5f0f<\/strong><\/td>\n<\/tr>\n<tr>\n<td>.<\/td>\n<td>Point marker<\/td>\n<\/tr>\n<tr>\n<td>,<\/td>\n<td>Pixel marker<\/td>\n<\/tr>\n<tr>\n<td>o<\/td>\n<td>Circle marker<\/td>\n<\/tr>\n<tr>\n<td>v<\/td>\n<td>Triangle down<\/td>\n<\/tr>\n<tr>\n<td>_<\/td>\n<td>Horizontal line<\/td>\n<\/tr>\n<tr>\n<td>|<\/td>\n<td>Vertical line<\/td>\n<\/tr>\n<tr>\n<td>d<\/td>\n<td>Thin diamond<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>Diamond marker<\/td>\n<\/tr>\n<tr>\n<td>+<\/td>\n<td>Plus marker<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u4f60\u89c9\u5f97\u6709\u7528\uff0c\u8bf7\u5206\u4eab\u6b64\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u672c\u7bc7Python Matplotlib \u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u63a7\u5236Matplotlib\u6837\u5f0f\uff0c\u56e0\u6b64\u60a8 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[129],"class_list":["post-1633","post","type-post","status-publish","format-standard","hentry","category-python","tag-matplotlib"],"aioseo_notices":[],"views":510,"_links":{"self":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/1633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/comments?post=1633"}],"version-history":[{"count":3,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/1633\/revisions"}],"predecessor-version":[{"id":1640,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/1633\/revisions\/1640"}],"wp:attachment":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/media?parent=1633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/categories?post=1633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/tags?post=1633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}