{"id":883,"date":"2017-04-11T21:40:39","date_gmt":"2017-04-11T12:40:39","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=883"},"modified":"2023-01-10T01:52:48","modified_gmt":"2023-01-09T16:52:48","slug":"matplotlib%e5%85%a5%e9%96%80-%e6%95%a3%e5%b8%83%e5%9b%b3%e7%b7%a83-%ef%bc%93%e6%ac%a1%e5%85%83%e6%95%a3%e5%b8%83%e5%9b%b3","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/883","title":{"rendered":"matplotlib 3\u6b21\u5143\u6563\u5e03\u56f3"},"content":{"rendered":"<p>matplotlib\u30673\u6b21\u5143\u306e\u6563\u5e03\u56f3\u3092\u63cf\u753b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002\uff08\u30ab\u30e9\u30fc\u30d0\u30fc\u306b\u95a2\u3059\u308b\u8a18\u4e8b\u306f<a href=\"http:\/\/www.python.ambitious-engineer.com\/archives\/2780\">\u3053\u3061\u3089<\/a>\u306b\u79fb\u52d5\u3057\u307e\u3057\u305f\u3002\uff09<\/p>\n<h2>3\u6b21\u5143\u6563\u5e03\u56f3<\/h2>\n<p>3\u6b21\u5143\u306e\u6563\u5e03\u56f3\u3092\u63cf\u753b\u3059\u308b\u5834\u5408\u3001mpl_toolkits.mplot3d.axes3d\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u8ffd\u52a0\u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002add_subplot\u306e\u5f15\u6570\u306bprojection='3d'\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom matplotlib import pyplot as plt\r\nimport numpy as np\r\n\r\n# \u30e9\u30f3\u30c0\u30e0\u306a\u70b9\u3092\u751f\u6210\r\nx = np.random.rand(50)\r\ny = np.random.rand(50)\r\nz = np.random.rand(50)\r\n\r\n# figure\u3092\u751f\u6210\r\nfig = plt.figure()\r\n\r\n# ax\u3092figure\u306b\u8a2d\u5b9a\r\nax = fig.add_subplot(1, 1, 1, projection='3d')\r\n\r\n# axes\u306bplot\r\nax.scatter(x, y, z, c='b')\r\n\r\n# \u8868\u793a\u3059\u308b\r\nplt.show()\r\n\r\n<\/pre>\n<p><strong>\u5b9f\u884c\u7d50\u679c<\/strong><br \/>\n<a href=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_1.png\"><img loading=\"lazy\" src=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_1.png\" alt=\"\" width=\"640\" height=\"587\" class=\"alignnone size-full wp-image-2802\" srcset=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_1.png 640w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_1-300x275.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>\u306a\u304a\u3001\u51fa\u529b\u7d50\u679c\u306b\u3064\u3044\u3066\u306f\u30de\u30a6\u30b9\u306e\u30c9\u30e9\u30c3\u30b0\u30fb\u30a2\u30f3\u30c9\u30fb\u30c9\u30ed\u30c3\u30d7\u3067\u65b9\u5411\u3092\u52d5\u304b\u3059\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p><strong>\u5225\u30a2\u30f3\u30b0\u30eb \u4e0b\u304b\u3089\u773a\u3081\u3066\u307f\u308b<\/strong><br \/>\n<a href=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_2.png\"><img loading=\"lazy\" src=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_2.png\" alt=\"\" width=\"640\" height=\"587\" class=\"alignnone size-full wp-image-2803\" srcset=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_2.png 640w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_2-300x275.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>\u63cf\u753b\u3059\u308b\u70b9\u304c\u591a\u304f\u306a\u308b\u3068\u3001\u74b0\u5883\u306b\u3088\u3063\u3066\u306f\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002\u3042\u3068\u3001\u5965\u306e\u70b9\u307b\u3069\u8272\u304c\u8584\u304f\u63cf\u753b\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u70b9\u304c\u6301\u3064\u5024\u304c\u8868\u73fe\u3055\u308c\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u3068\u3044\u3046\u70b9\u306b\u7559\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u70b9\u304c\u6301\u3064\u5024\u3084\u91cf\u3092\u8868\u3059\u5834\u5408\u306f\u6b21\u306b\u8aac\u660e\u3059\u308b\u30ab\u30e9\u30fc\u30d0\u30fc\u3092\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>3\u6b21\u5143\u3067\u30ab\u30e9\u30fc\u30d0\u30fc\u3092\u5229\u7528\u3059\u308b\u5834\u5408<\/h2>\n<p>\u5148\u7a0b\u306e\u6563\u5e03\u56f3\u3067\u306f\u5358\u7d14\u306b3\u6b21\u5143\u7a7a\u9593\u4e0a\u306e\u70b9\u306e\u5206\u5e03\u306b\u3064\u3044\u3066\u8868\u73fe\u3057\u3066\u3044\u307e\u3057\u305f\u3002\u30ab\u30e9\u30fc\u30d0\u30fc\u3092\u4f7f\u3046\u30683\u6b21\u5143\u4e0a\u306e\u70b9\u306e\u5206\u5e03\u306b\u52a0\u3048\u3001\u305d\u308c\u305e\u308c\u6301\u3064\u91cf\u3092\u53ef\u8996\u5316\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u4f8b\u3048\u3070\u89b3\u6e2c\u65bd\u8a2d\u5185\u306b\u8a2d\u7f6e\u3057\u305f\u30bb\u30f3\u30b5\u30fc\u3067\u5f97\u305f\u6c17\u6e29\u7b49\u306e\u5024\u306e\u5206\u5e03\u3092\u8868\u73fe\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u30ab\u30e9\u30fc\u30de\u30c3\u30d7\u3092\u4f7f\u7528\u3057\u307e\u3059\u304c\u305d\u308c\u306b\u3064\u3044\u3066\u306f\u524d\u56de\u306e\u8a18\u4e8b\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<a href=\"http:\/\/www.python.ambitious-engineer.com\/archives\/2780\">matplotlib \u30ab\u30e9\u30fc\u30d0\u30fc\u4ed8\u304d\u6563\u5e03\u56f3<\/a><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom matplotlib import pyplot as plt\r\nimport numpy as np\r\n\r\n# \u30e9\u30f3\u30c0\u30e0\u306a\u70b9\u3092\u751f\u6210\u3059\u308b(x, y, z\u5ea7\u6a19)\r\nx = np.random.rand(50)\r\ny = np.random.rand(50)\r\nz = np.random.rand(50)\r\n\r\n# \u70b9(x, y, z)\u304c\u3082\u3064\u91cf\r\nvalue = np.random.rand(50)\r\n\r\n# figure\u3092\u751f\u6210\u3059\u308b\r\nfig = plt.figure()\r\n\r\n# ax\u3092figure\u306b\u8a2d\u5b9a\u3059\u308b\r\nax = fig.add_subplot(1, 1, 1, projection='3d')\r\n\r\n# \u30ab\u30e9\u30fc\u30de\u30c3\u30d7\u3092\u751f\u6210\r\ncm = plt.cm.get_cmap('RdYlBu')\r\n\r\n# ax\u306b\u6563\u5e03\u56f3\u3092\u63cf\u753b\u3001\u623b\u308a\u5024\u306bPathCollection\u3092\u5f97\u308b\r\nmappable = ax.scatter(x, y, c=value, cmap=cm)\r\nfig.colorbar(mappable, ax=ax)\r\n\r\n# \u8868\u793a\u3059\u308b\r\nplt.show()\r\n<\/pre>\n<p><strong>\u5b9f\u884c\u7d50\u679c<\/strong><br \/>\n<a href=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_color1.png\"><img loading=\"lazy\" src=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_color1.png\" alt=\"\" width=\"640\" height=\"587\" class=\"alignnone size-full wp-image-2804\" srcset=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_color1.png 640w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/04\/scatter_3d_color1-300x275.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>\u4e0a\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u306f3\u6b21\u5143\u4e0a\u306e\u5ea7\u6a19\u5217x, y, z\u306b\u52a0\u3048\u3001value\u304c\u305d\u308c\u305e\u308c\u306e\u70b9\u304c\u3082\u3064\u5024\u306e\u914d\u5217\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>matplotlib3.5\u4ee5\u524d<\/h2>\n<p>\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u306e\u901a\u308aAxes3D\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom matplotlib import pyplot as plt\r\nimport numpy as np\r\nfrom mpl_toolkits.mplot3d import Axes3D\r\n\r\n\r\n# \u30e9\u30f3\u30c0\u30e0\u306a\u70b9\u3092\u751f\u6210\u3059\u308b(x, y, z\u5ea7\u6a19)\r\nx = np.random.rand(50)\r\ny = np.random.rand(50)\r\nz = np.random.rand(50)\r\n\r\n# figure\u3092\u751f\u6210\r\nfig = plt.figure()\r\n\r\n# ax\u3092figure\u306b\u8a2d\u5b9a\r\nax = Axes3D(fig, auto_add_to_figure=False)\r\nfig.add_axes(ax)\r\n\r\n# axes\u306b\u6563\u5e03\u56f3\u3092\u8a2d\u5b9a\r\nax.scatter(x, y, z, c='b')\r\n\r\n# \u8868\u793a\r\nplt.show()\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>matplotlib\u30673\u6b21\u5143\u306e\u6563\u5e03\u56f3\u3092\u63cf\u753b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002\uff08\u30ab\u30e9\u30fc\u30d0\u30fc\u306b\u95a2\u3059\u308b\u8a18\u4e8b\u306f\u3053\u3061\u3089\u306b\u79fb\u52d5\u3057\u307e\u3057\u305f\u3002\uff09 3\u6b21\u5143\u6563\u5e03\u56f3 3\u6b21\u5143\u306e\u6563\u5e03\u56f3\u3092\u63cf\u753b\u3059\u308b\u5834\u5408\u3001mpl_toolkits.mplot3d.axes3d...<\/p>\n","protected":false},"author":1,"featured_media":2804,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[154],"tags":[155,170,203],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/883"}],"collection":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=883"}],"version-history":[{"count":5,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/883\/revisions"}],"predecessor-version":[{"id":2801,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/883\/revisions\/2801"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/2804"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}