{"id":1001,"date":"2023-07-28T01:09:20","date_gmt":"2023-07-28T01:09:20","guid":{"rendered":"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/"},"modified":"2023-07-28T01:09:20","modified_gmt":"2023-07-28T01:09:20","slug":"spaziatura-della-sottotrama-matplotlib","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/","title":{"rendered":"Come regolare la spaziatura tra le sottotrame matplotlib"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Spesso puoi utilizzare le sottotrame per visualizzare pi\u00f9 grafici uno accanto all&#8217;altro in Matplotlib. Sfortunatamente, queste sottotrame tendono a sovrapporsi per impostazione predefinita.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Il modo pi\u00f9 semplice per risolvere questo problema \u00e8 utilizzare la funzione Matplotlib <a href=\"https:\/\/matplotlib.org\/api\/_as_gen\/matplotlib.pyplot.tight_layout.html\" target=\"_blank\" rel=\"noopener noreferrer\">Tight_layout()<\/a> . Questo tutorial spiega come utilizzare questa funzione nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Crea sottotrame<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Considera la seguente disposizione di 4 sottotrame in 2 colonne e 2 righe:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> matplotlib.pyplot <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#define subplots<\/span>\nfig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> (2, 2)\n\n<span style=\"color: #008080;\">#display subplots<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10376 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-intrigueespace1.png\" alt=\"\" width=\"416\" height=\"274\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Nota come le sottotrame si sovrappongono un po&#8217;.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Regola la spaziatura della sottotrama usando Tight_layout()<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il modo pi\u00f9 semplice per risolvere questo problema di sovrapposizione \u00e8 utilizzare la funzione Matplotlib <strong>Tight_layout()<\/strong> :<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> matplotlib.pyplot <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#define subplots<\/span>\nfig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> (2, 2)\nfig. <span style=\"color: #3366ff;\">tight_layout<\/span> ()\n\n<span style=\"color: #008080;\">#display subplots<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10377 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-intrigueespace2.png\" alt=\"Regola la spaziatura della sottotrama Matplotlib\" width=\"437\" height=\"292\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Regola la spaziatura dei titoli della sottotrama<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In alcuni casi, puoi anche avere titoli per ciascuna delle tue sottotrame. Sfortunatamente, anche la funzione <strong>Tight_layout()<\/strong> tende a causare la sovrapposizione dei titoli delle sottotrame:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> matplotlib.pyplot <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#define subplots<\/span>\nfig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> (2, 2)\nfig. <span style=\"color: #3366ff;\">tight_layout<\/span> ()\n\n<span style=\"color: #008080;\">#define subplot titles<\/span>\nax[0, 0]. <span style=\"color: #3366ff;\">set_title<\/span> ('First Subplot')\nax[0, 1]. <span style=\"color: #3366ff;\">set_title<\/span> ('Second Subplot')\nax[1, 0]. <span style=\"color: #3366ff;\">set_title<\/span> ('Third Subplot')\nax[1, 1]. <span style=\"color: #3366ff;\">set_title<\/span> ('Fourth Subplot')\n\n<span style=\"color: #008080;\">#display subplots<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10378 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-intrigueespace3.png\" alt=\"Sottotrame con titoli in Matplotlib\" width=\"439\" height=\"308\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Il modo per risolvere questo problema \u00e8 aumentare l&#8217;imbottitura in altezza tra le sottotrame utilizzando l&#8217;argomento <strong>h_pad<\/strong> :<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> matplotlib.pyplot <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#define subplots<\/span>\nfig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> (2, 2)\nfig. <span style=\"color: #3366ff;\">tight_layout<\/span> (h_pad= <span style=\"color: #008000;\">2<\/span> )\n\n<span style=\"color: #008080;\">#define subplot titles<\/span>\nax[0, 0]. <span style=\"color: #3366ff;\">set_title<\/span> ('First Subplot')\nax[0, 1]. <span style=\"color: #3366ff;\">set_title<\/span> ('Second Subplot')\nax[1, 0]. <span style=\"color: #3366ff;\">set_title<\/span> ('Third Subplot')\nax[1, 1]. <span style=\"color: #3366ff;\">set_title<\/span> ('Fourth Subplot')\n\n<span style=\"color: #008080;\">#display subplots<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10379 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-intrigueespace4.png\" alt=\"Spaziatura delle intestazioni della sottotrama Matplotlib\" width=\"419\" height=\"297\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Regola la spaziatura complessiva del titolo<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Se hai un titolo generale, puoi utilizzare la funzione <strong>subplots_adjust()<\/strong> per assicurarti che non si sovrapponga ai titoli della sottotrama:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> matplotlib.pyplot <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#define subplots<\/span>\nfig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> (2, 2)\nfig. <span style=\"color: #3366ff;\">tight_layout<\/span> (h_pad= <span style=\"color: #008000;\">2<\/span> )\n\n<span style=\"color: #008080;\">#define subplot titles<\/span>\nax[0, 0]. <span style=\"color: #3366ff;\">set_title<\/span> ('First Subplot')\nax[0, 1]. <span style=\"color: #3366ff;\">set_title<\/span> ('Second Subplot')\nax[1, 0]. <span style=\"color: #3366ff;\">set_title<\/span> ('Third Subplot')\nax[1, 1]. <span style=\"color: #3366ff;\">set_title<\/span> ('Fourth Subplot')\n\n<span style=\"color: #008080;\">#add overall title and adjust it so that it doesn't overlap with subplot titles<\/span>\nfig.suptitle(' <span style=\"color: #008000;\">Overall Title<\/span> ')\nplt.subplots_adjust(top= <span style=\"color: #008000;\">0.85<\/span> )\n\n<span style=\"color: #008080;\">#display subplots<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10380 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-intrigueespace5.png\" alt=\"Spaziatura delle intestazioni in Matplotlib\" width=\"443\" height=\"296\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><em>Puoi trovare altri tutorial su Matplotlib qui .<\/em><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spesso puoi utilizzare le sottotrame per visualizzare pi\u00f9 grafici uno accanto all&#8217;altro in Matplotlib. Sfortunatamente, queste sottotrame tendono a sovrapporsi per impostazione predefinita. Il modo pi\u00f9 semplice per risolvere questo problema \u00e8 utilizzare la funzione Matplotlib Tight_layout() . Questo tutorial spiega come utilizzare questa funzione nella pratica. Crea sottotrame Considera la seguente disposizione di 4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come regolare la spaziatura tra le sottotrame Matplotlib - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come regolare la spaziatura tra le sottotrame in Matplotlib, con diversi esempi.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come regolare la spaziatura tra le sottotrame Matplotlib - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come regolare la spaziatura tra le sottotrame in Matplotlib, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T01:09:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-intrigueespace1.png\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/\",\"url\":\"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/\",\"name\":\"Come regolare la spaziatura tra le sottotrame Matplotlib - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-28T01:09:20+00:00\",\"dateModified\":\"2023-07-28T01:09:20+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come regolare la spaziatura tra le sottotrame in Matplotlib, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come regolare la spaziatura tra le sottotrame matplotlib\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come regolare la spaziatura tra le sottotrame Matplotlib - Statorials","description":"Questo tutorial spiega come regolare la spaziatura tra le sottotrame in Matplotlib, con diversi esempi.","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:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/","og_locale":"it_IT","og_type":"article","og_title":"Come regolare la spaziatura tra le sottotrame Matplotlib - Statorials","og_description":"Questo tutorial spiega come regolare la spaziatura tra le sottotrame in Matplotlib, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/","og_site_name":"Statorials","article_published_time":"2023-07-28T01:09:20+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-intrigueespace1.png"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/","url":"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/","name":"Come regolare la spaziatura tra le sottotrame Matplotlib - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-28T01:09:20+00:00","dateModified":"2023-07-28T01:09:20+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come regolare la spaziatura tra le sottotrame in Matplotlib, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/spaziatura-della-sottotrama-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come regolare la spaziatura tra le sottotrame matplotlib"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1001"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=1001"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1001\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}