{"id":2238,"date":"2023-07-23T03:16:00","date_gmt":"2023-07-23T03:16:00","guid":{"rendered":"https:\/\/statorials.org\/it\/sottotrame-marine\/"},"modified":"2023-07-23T03:16:00","modified_gmt":"2023-07-23T03:16:00","slug":"sottotrame-marine","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/sottotrame-marine\/","title":{"rendered":"Come creare sottotrame in seaborn (con esempi)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi di base per creare sottotrame nella libreria di visualizzazione dati <a href=\"https:\/\/seaborn.pydata.org\/\" target=\"_blank\" rel=\"noopener\">Seaborn<\/a> in Python:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define dimensions of subplots (rows, columns)\n<\/span>fig, axes = plt. <span style=\"color: #3366ff;\">subplots<\/span> (2, 2)\n\n<span style=\"color: #008080;\">#create chart in each subplot\n<\/span>sns. <span style=\"color: #3366ff;\">boxplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">points<\/span> ', ax=axes[0,0])\nsns. <span style=\"color: #3366ff;\">boxplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">assists<\/span> ', ax=axes[0,1])\n\n...\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">L&#8217;esempio seguente mostra come utilizzare questa sintassi nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio: creazione di sottotrame in Seaborn<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Supponiamo di avere i seguenti panda DataFrame:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#createDataFrame<span style=\"color: #000000;\">\ndf = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': [19, 12, 15, 14, 19, 23, 25, 29],\n                   ' <span style=\"color: #ff0000;\">assists<\/span> ': [13, 15, 11, 8, 6, 8, 11, 14],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': [11, 7, 8, 12, 13, 7, 6, 8],\n                   ' <span style=\"color: #ff0000;\">blocks<\/span> ': [1, 2, 2, 3, 5, 4, 3, 3]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n  team points assists rebounds blocks\n0 A 19 13 11 1\n1 A 12 15 7 2\n2 A 15 11 8 2\n3 A 14 8 12 3\n4 B 19 6 13 5\n5 B 23 8 7 4\n6 B 25 11 6 3\n7 B 29 14 8 3<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come definire un&#8217;area del grafico con due righe e due colonne e creare un boxplot in ogni sottotrama per ciascuna delle quattro variabili numeriche nel DataFrame:<\/span> <\/p>\n<pre style=\"background-color: #ececec;\"> <span style=\"font-size: 15px; color: #008000; font-weight: bold;\">import<\/span> <span style=\"font-size: 15px;\"><b>matplotlib.<\/b><\/span> <span style=\"font-size: 15px; color: #3366ff; font-weight: bold;\">pyplot<\/span><b> <\/b><span style=\"font-size: 15px; color: #008000; font-weight: bold;\">as<\/span> <span style=\"font-size: 15px;\"><b>plt\n<\/b><\/span><span style=\"font-size: 15px; color: #008000; font-weight: bold;\">import<\/span> <span style=\"font-size: 15px;\"><b>seaborn<\/b><\/span> <span style=\"font-size: 15px; color: #008000; font-weight: bold;\">as<\/span> <span style=\"font-size: 15px;\"><b>sns\n\n<span style=\"color: #008080;\">#set seaborn plotting aesthetics as default<\/span>\n<\/b><\/span><span style=\"font-size: 15px;\"><b>sns.<\/b><\/span> <span style=\"font-size: 15px; color: #3366ff; font-weight: bold;\">set<\/span> <span style=\"font-size: 15px;\"><b>()\n\n<span style=\"color: #008080;\">#define plotting region (2 rows, 2 columns)\n<\/span>fig, axes = plt.<\/b><\/span> <span style=\"font-size: 15px; color: #3366ff; font-weight: bold;\">subplots<\/span> <span style=\"font-size: 15px;\"><b>(2, 2)\n\n<\/b><\/span><span style=\"font-size: 15px; color: #008080; font-weight: bold;\">#create boxplot in each subplot\n<\/span><span style=\"font-size: 15px;\"><b>sns. <span style=\"color: #3366ff;\">boxplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">points<\/span> ', ax=axes[0,0])\nsns. <span style=\"color: #3366ff;\">boxplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">assists<\/span> ', ax=axes[0,1])\nsns. <span style=\"color: #3366ff;\">boxplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">rebounds<\/span> ', ax=axes[1,0])\nsns. <span style=\"color: #3366ff;\">boxplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">blocks<\/span> ', ax=axes[1,1])\n<\/b><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-20473\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/seabornsub1.png\" alt=\"sottotrame marine in Python\" width=\"636\" height=\"465\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">In questo esempio, abbiamo creato una regione del tracciato con due righe e due colonne e riempito ciascuna sottotrama con boxplot.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Tuttavia, possiamo utilizzare una sintassi simile per creare una regione del grafico con dimensioni diverse e popolare le sottotrame con grafici diversi.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, il codice seguente mostra come creare un&#8217;area del grafico con una riga e due colonne e riempire ogni grafico con un grafico a violino:<\/span> <\/p>\n<pre style=\"background-color: #ececec;\"> <span style=\"font-size: 15px; color: #008000; font-weight: bold;\">import<\/span> <span style=\"font-size: 15px;\"><b>matplotlib.<\/b><\/span> <span style=\"font-size: 15px; color: #3366ff; font-weight: bold;\">pyplot<\/span><b> <\/b><span style=\"font-size: 15px; color: #008000; font-weight: bold;\">as<\/span> <span style=\"font-size: 15px;\"><b>plt\n<\/b><\/span><span style=\"font-size: 15px; color: #008000; font-weight: bold;\">import<\/span> <span style=\"font-size: 15px;\"><b>seaborn<\/b><\/span> <span style=\"font-size: 15px; color: #008000; font-weight: bold;\">as<\/span> <span style=\"font-size: 15px;\"><b>sns\n\n<span style=\"color: #008080;\">#set seaborn plotting<\/span><\/b><\/span> <span style=\"color: #008080;\"><span style=\"font-size: 15px;\"><b>aesthetics<\/b><\/span><\/span> <span style=\"font-size: 15px;\"><b><span style=\"color: #008080;\">as default\n<\/span>sns.<\/b><\/span> <span style=\"font-size: 15px; color: #3366ff; font-weight: bold;\">set<\/span> <span style=\"font-size: 15px;\"><b>()\n\n<span style=\"color: #008080;\">#define plotting region (1 row, 2 columns)\n<\/span>fig, axes = plt.<\/b><\/span> <span style=\"font-size: 15px; color: #3366ff; font-weight: bold;\">subplots<\/span> <span style=\"font-size: 15px;\"><b>(1, 2)\n\n<\/b><\/span><span style=\"font-size: 15px; color: #008080; font-weight: bold;\">#create boxplot in each subplot\n<\/span><span style=\"font-size: 15px;\"><b>sns. <span style=\"color: #3366ff;\">violinplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">points<\/span> ', ax=axes[0])\nsns. <span style=\"color: #3366ff;\">violinplot<\/span> (data=df, x=' <span style=\"color: #ff0000;\">team<\/span> ', y=' <span style=\"color: #ff0000;\">assists<\/span> ', ax=axes[1])\n<\/b><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-20474 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/seabornsub2.png\" alt=\"\" width=\"545\" height=\"382\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altre funzioni comuni in Seaborn:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/titolo-marino\/\" target=\"_blank\" rel=\"noopener\">Come aggiungere un titolo alle trame di Seaborn<\/a><br \/> Come salvare la trama di Seaborn in un file<br \/> <a href=\"https:\/\/statorials.org\/it\/posizione-della-leggenda-del-mare\/\" target=\"_blank\" rel=\"noopener\">Come cambiare la posizione di una leggenda in Seaborn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi di base per creare sottotrame nella libreria di visualizzazione dati Seaborn in Python: #define dimensions of subplots (rows, columns) fig, axes = plt. subplots (2, 2) #create chart in each subplot sns. boxplot (data=df, x=&#8217; team &#8216;, y=&#8217; points &#8216;, ax=axes[0,0]) sns. boxplot (data=df, x=&#8217; team &#8216;, y=&#8217; assists [&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 creare sottotrame in Seaborn (con esempi) \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come creare sottotrame in Seaborn, 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\/sottotrame-marine\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come creare sottotrame in Seaborn (con esempi) \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come creare sottotrame in Seaborn, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/sottotrame-marine\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T03:16:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/seabornsub1.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\/sottotrame-marine\/\",\"url\":\"https:\/\/statorials.org\/it\/sottotrame-marine\/\",\"name\":\"Come creare sottotrame in Seaborn (con esempi) \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-23T03:16:00+00:00\",\"dateModified\":\"2023-07-23T03:16:00+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come creare sottotrame in Seaborn, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/sottotrame-marine\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/sottotrame-marine\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/sottotrame-marine\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come creare sottotrame in seaborn (con esempi)\"}]},{\"@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 creare sottotrame in Seaborn (con esempi) \u2013 Statorials","description":"Questo tutorial spiega come creare sottotrame in Seaborn, 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\/sottotrame-marine\/","og_locale":"it_IT","og_type":"article","og_title":"Come creare sottotrame in Seaborn (con esempi) \u2013 Statorials","og_description":"Questo tutorial spiega come creare sottotrame in Seaborn, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/sottotrame-marine\/","og_site_name":"Statorials","article_published_time":"2023-07-23T03:16:00+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/seabornsub1.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\/sottotrame-marine\/","url":"https:\/\/statorials.org\/it\/sottotrame-marine\/","name":"Come creare sottotrame in Seaborn (con esempi) \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-23T03:16:00+00:00","dateModified":"2023-07-23T03:16:00+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come creare sottotrame in Seaborn, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/sottotrame-marine\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/sottotrame-marine\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/sottotrame-marine\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come creare sottotrame in seaborn (con esempi)"}]},{"@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\/2238"}],"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=2238"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/2238\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=2238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=2238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=2238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}