{"id":1554,"date":"2020-07-11T00:00:00","date_gmt":"2020-07-10T15:00:00","guid":{"rendered":"https:\/\/www.ishikawasekkei.com\/?p=1554"},"modified":"2020-07-11T18:18:44","modified_gmt":"2020-07-11T09:18:44","slug":"python-programing-matplotlib-subplot-output-order-change","status":"publish","type":"post","link":"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/07\/11\/python-programing-matplotlib-subplot-output-order-change\/","title":{"rendered":"Python \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 matplotlib subplot\u306e\u51fa\u529b\u9806\u3092\u5909\u66f4\u3057\u305f\u3044"},"content":{"rendered":"\n<p>\u3000\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3055\u3066\u3001\u4eca\u56de\u306f\u3001matplotlib\u306esubplot\u3068\u30bf\u30a4\u30c8\u30eb\u306b\u3042\u308a\u307e\u3059\u304c\u3001\u30e1\u30a4\u30f3\u306fsubplot\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u306d\u3002subplot\u306e\u51fa\u529b\u9806\u3092\u5909\u66f4\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u3060\u3051\u306e\u3001\u6a19\u6e96\u7684\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u304a\u8a71\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3084\u308a\u305f\u3044\u3053\u3068<\/h2>\n\n\n\n<p>\u3000\u901a\u5e38\u3001subplot\u3092\u4f7f\u3046\u3068\u3001\u8907\u6570\u306e\u30b0\u30e9\u30d5\u3092\u4e26\u3079\u3066\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u3093\u306a\u5177\u5408\u3067\u3059\u3002<a href=\"https:\/\/matplotlib.org\/3.1.0\/gallery\/lines_bars_and_markers\/scatter_star_poly.html#sphx-glr-gallery-lines-bars-and-markers-scatter-star-poly-py\" target=\"_blank\" rel=\"noreferrer noopener\">\u3053\u3061\u3089\u306e\u30b5\u30a4\u30c8<\/a>\u3092\u53c2\u8003\u306b\u51fa\u529b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"597\" src=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-3.png\" alt=\"\" class=\"wp-image-1556\" srcset=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-3.png 642w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-3-300x279.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><figcaption>subplot\u30b5\u30f3\u30d7\u30eb<\/figcaption><\/figure>\n\n\n\n<p>\u3000\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.random.rand(10)\ny = np.random.rand(10)\nz = np.sqrt(x**2 + y**2)\nverts = np.array([[-1, -1], [1, -1], [1, 1], [-1, -1]])\nmarkers = (\">\", (5, 0), verts, (5, 1), '+', (5, 2))\n\nfor i, m in enumerate(markers, 1):\n    plt.subplot(3, 2, i)\n    plt.scatter(x, y, s=80, c=z, marker=m)\n\nplt.show()<\/pre>\n\n\n\n<p>\u300011\u884c\u76ee\u306e\u3001plt.subplot(3, 2, i)\u3067\u30b5\u30d6\u30d7\u30ed\u30c3\u30c8\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\u6700\u521d\u306e\u4e8c\u3064\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u884c\u5217\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u30013\u884c2\u5217\u3092\u8868\u3057\u307e\u3059\u3002i\u306f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u5024\u3067\u30011\u304b\u3089\u9806\u756a\u306b\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3001\u5de6\u304b\u3089\u53f3\u3001\u4e0a\u304b\u3089\u4e0b\u3078\u30013\u884c2\u5217\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u9806\u756a\u3067\u51fa\u529b\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"597\" src=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-5.png\" alt=\"\" class=\"wp-image-1560\" srcset=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-5.png 642w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-5-300x279.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/figure>\n\n\n\n<p>subplot\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u51fa\u529b\u9806<\/p>\n\n\n\n<p>\u3000\u3053\u308c\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u51fa\u529b\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u8981\u671b\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"597\" src=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-6.png\" alt=\"\" class=\"wp-image-1561\" srcset=\"https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-6.png 642w, https:\/\/www.ishikawasekkei.com\/wp-content\/uploads\/2020\/07\/image-6-300x279.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><figcaption>subplot\u51fa\u529b\u9806\u3092\u3053\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u305f\u3044<\/figcaption><\/figure>\n\n\n\n<p>\u3000subplot\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u304b\u4f55\u304b\u3067\u7c21\u5358\u306b\u5909\u66f4\u3067\u304d\u306a\u3044\u304b\u3068\u601d\u3063\u3066\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u305d\u306e\u3088\u3046\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u898b\u3064\u3051\u3089\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u304b\u308f\u308a\u306bsubplots\u3092\u4f7f\u3063\u3066\u884c\u5217\u306e\u914d\u5217\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3053\u308c\u306a\u3089\u3070\u3001\u4eca\u56de\u306e\u3088\u3046\u306a\u5de5\u592b\u306f\u5fc5\u8981\u306a\u3055\u305d\u3046\u3067\u3059\u3002\u307e\u3001\u3067\u3082\u3001\u4eca\u56de\u306f\u982d\u306e\u4f53\u64cd\u3067\u3059\u306d\u3002\u3082\u3063\u3068\u7c21\u5358\u306a\u65b9\u6cd5\u304c\u3042\u308c\u3070\u3001\u3069\u306a\u305f\u304b\u6559\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u30001\uff5e6\u306e\u30eb\u30fc\u30d7\u3092\u5272\u308a\u7b97\u3057\u305f\u308a\u3001\u4f59\u308a\u3092\u6c42\u3081\u305f\u308a\u3001numpy.transpose()\u304c\u4f7f\u3048\u308b\u304b\u3082\u3001\u3068\u3001\u691c\u8a0e\u3057\u3066\u307f\u305f\u3051\u3069\u3001\u3053\u308c\u306f\u884c\u5217\u304c\u540c\u3058\u6570\u306e\u3068\u304d\u3057\u304b\u4f7f\u3048\u306a\u3044\u3068\u304b\u3001\u3044\u308d\u3044\u308d\u3068\u5b9f\u9a13\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u305d\u306e\u7d50\u679c\u3001\u4eca\u56de\u306f\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092[1, 3, 5, 2, 4, 6]\u3068\u3044\u3046\u3075\u3046\u306b\u51fa\u529b\u3059\u308c\u3070\u671b\u307f\u3069\u304a\u308a\u306b\u51fa\u529b\u3067\u304d\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002\u3053\u3053\u307e\u3067\u304f\u308c\u3070\u3082\u3046\u3067\u304d\u305f\u3082\u540c\u7136\u3067\u3059\u306d\u3002\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.random.rand(10)\ny = np.random.rand(10)\nz = np.sqrt(x**2 + y**2)\nverts = np.array([[-1, -1], [1, -1], [1, 1], [-1, -1]])\nmarkers = (\">\", (5, 0), verts, (5, 1), '+', (5, 2))\n\n\ndef index_generator(row, col):\n    for c in range(col):\n        for i in range(c + 1, row * col + 1, col):\n            yield i\n\n\nindex = index_generator(3, 2)\n\nfor i, m in zip(index, markers):\n    plt.subplot(3, 2, i)\n    plt.scatter(x, y, s=80, c=z, marker=m)\n\nplt.show()<\/pre>\n\n\n\n<p>\u3000\u30dd\u30a4\u30f3\u30c8\u306f11\uff5e14\u884c\u76ee\u3001\u77e5\u3063\u305f\u304b\u3076\u308a\u3092\u3057\u3066\u3001\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u884c\u3001\u5217\u3067\u3059\u3002\u95a2\u6570\u5185\u3067\u306f\u3001\u5217\u6570\u5206\u7e70\u308a\u8fd4\u3057\u307e\u3059\u304c\u30011\u304b\u3089\u59cb\u3081\u3066\u5217\u6570\u3054\u3068\u306b\u6570\u5b57\u3092\u53d6\u308a\u51fa\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u30013\u884c2\u5217\u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u3001\u5217\u306e1\u56de\u76ee\u306e\u30eb\u30fc\u30d7\u3067\u30011\u30013\u30015\u3001\u3092\u623b\u3057\u3001\u5217\u306e2\u56de\u76ee\u306e\u30eb\u30fc\u30d7\u3067\u30012\u30014\u30016\u3092\u53d6\u308a\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u300014\u884c\u76ee\u306e\u300cyield i\u300d\u3092\u4f7f\u3046\u3053\u3068\u3067\u95a2\u6570\u304c\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u306b\u306a\u308a\u307e\u3059\u3002\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u306f\u3001\u6b21\u306e\u8981\u7d20\u304c\u53d6\u308a\u51fa\u3055\u308c\u308b\u307e\u3067\u3001\u5024\u3092\u751f\u6210\u3057\u306a\u3044\u306e\u3067\u30e1\u30e2\u30ea\u304c\u7bc0\u7d04\u3067\u304d\u308b\u3001\u3068\u3044\u3046\u7279\u5fb4\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u300017\u884c\u76ee\u3067index\u3092\u5b9a\u7fa9\u3057\u3066\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u751f\u6210\u306b\u306f\u3053\u3061\u3089\u3092\u5229\u7528\u3057\u307e\u3059\u3002\u3068\u3044\u3046\u3053\u3068\u3067\u300119\u884c\u76ee\u306efor\u30eb\u30fc\u30d7\u3082enumerate\u3092\u3084\u3081\u3066\u3001zip\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3000\u5272\u308a\u7b97\u3084\u4f59\u308a\u3092\u4f7f\u3063\u3066\u8a08\u7b97\u3067\u3067\u304d\u308b\u306e\u3067\u306f\u3001\u3068\u3001\u7c21\u5358\u305d\u3046\u306b\u601d\u3044\u307e\u3057\u305f\u304c\u3001\u5b9f\u306f\u3001\u3061\u3087\u3063\u3068\u3072\u306d\u308a\u304c\u5fc5\u8981\u3060\u3063\u305f\u3068\u3044\u3046\u3001\u3088\u3044\u554f\u984c\u3067\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002 \u3000\u3055\u3066\u3001\u4eca\u56de\u306f\u3001matplotlib\u306esubplot\u3068\u30bf\u30a4\u30c8\u30eb\u306b\u3042\u308a\u307e\u3059\u304c\u3001\u30e1\u30a4\u30f3\u306fsubplot\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u306d\u3002subplot\u306e\u51fa\u529b\u9806\u3092\u5909\u66f4\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u3060 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/07\/11\/python-programing-matplotlib-subplot-output-order-change\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Python \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 matplotlib subplot\u306e\u51fa\u529b\u9806\u3092\u5909\u66f4\u3057\u305f\u3044&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,2],"tags":[],"class_list":["post-1554","post","type-post","status-publish","format-standard","hentry","category-program","category-blog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/comments?post=1554"}],"version-history":[{"count":8,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1554\/revisions"}],"predecessor-version":[{"id":1566,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1554\/revisions\/1566"}],"wp:attachment":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/media?parent=1554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/categories?post=1554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/tags?post=1554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}