{"id":1188,"date":"2023-07-27T08:47:37","date_gmt":"2023-07-27T08:47:37","guid":{"rendered":"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/"},"modified":"2023-07-27T08:47:37","modified_gmt":"2023-07-27T08:47:37","slug":"riempimento-matplotlib-tra","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/","title":{"rendered":"Come riempire le aree tra le righe in matplotlib"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Puoi facilmente riempire l&#8217;area tra i valori in un grafico Matplotlib utilizzando le seguenti funzioni:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><a href=\"https:\/\/matplotlib.org\/3.3.2\/api\/_as_gen\/matplotlib.pyplot.fill_between.html\" target=\"_blank\" rel=\"noopener noreferrer\">fill_between()<\/a> : riempie l&#8217;area tra due curve orizzontali.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><a href=\"https:\/\/matplotlib.org\/3.3.2\/api\/_as_gen\/matplotlib.pyplot.fill_betweenx.html#matplotlib.pyplot.fill_betweenx\" target=\"_blank\" rel=\"noopener noreferrer\">fill_betweenx()<\/a> : riempie l&#8217;area tra due curve verticali.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Questo tutorial fornisce esempi di come utilizzare ciascuna di queste funzioni nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: riempire l&#8217;area tra due linee orizzontali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come riempire l&#8217;area tra due linee orizzontali:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#define x and y values\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (0,10,0.1)\ny = np. <span style=\"color: #3366ff;\">arange<\/span> (10,20,0.1)\n\n<span style=\"color: #008080;\">#create plot of values\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x,y)\n\n<span style=\"color: #008080;\">#fill in area between the two lines\n<\/span>plt. <span style=\"color: #3366ff;\">fill_between<\/span> (x,y,color=' <span style=\"color: #008000;\">red<\/span> ')\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11808 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/remplirentre1.png\" alt=\"Riempi l'area tra le linee in Matplotlib\" width=\"428\" height=\"286\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che possiamo anche utilizzare la funzione <strong>plt.grid()<\/strong> per aggiungere una griglia al grafico per vedere pi\u00f9 facilmente quali valori sono riempiti:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#define x and y values\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (0,10,0.1)\ny = np. <span style=\"color: #3366ff;\">arange<\/span> (10,20,0.1)\n\n<span style=\"color: #008080;\">#create plot of values\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x,y)\n\n<span style=\"color: #008080;\">#fill in area between the two lines\n<\/span>plt. <span style=\"color: #3366ff;\">fill_between<\/span> (x, y, color=' <span style=\"color: #008000;\">red<\/span> ', alpha= <span style=\"color: #008000;\">.5<\/span> )\n\n<span style=\"color: #008080;\">#add gridlines<\/span>\nplt. <span style=\"color: #3366ff;\">grid<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11809 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/remplirentre2.png\" alt=\"Riempi l'area tra le linee matplotlib\" width=\"420\" height=\"276\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: riempire l&#8217;area sotto una curva<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come riempire l&#8217;area sotto una curva:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#define x and y values\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (0,10,0.1)\ny = x**4\n\n<span style=\"color: #008080;\">#create plot of values\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x,y)\n\n<span style=\"color: #008080;\">#fill in area between the two lines\n<\/span>plt. <span style=\"color: #3366ff;\">fill_between<\/span> (x, y, color=' <span style=\"color: #008000;\">red<\/span> ', alpha= <span style=\"color: #008000;\">.5<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11810 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/remplirentre3.png\" alt=\"Riempi tra Matplotlib\" width=\"446\" height=\"287\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 3: riempire l&#8217;area sopra una curva<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come riempire l&#8217;area sopra una curva:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#define x and y values\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (0,10,0.1)\ny = x**4\n\n<span style=\"color: #008080;\">#create plot of values\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x,y)\n\n<span style=\"color: #008080;\">#fill in area between the two lines\n<\/span>plt. <span style=\"color: #3366ff;\">fill_between<\/span> (x, y, np. <span style=\"color: #3366ff;\">max<\/span> (y), color=' <span style=\"color: #008000;\">red<\/span> ', alpha= <span style=\"color: #008000;\">.5<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11811 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/remplirentre4.png\" alt=\"Riempi l'area sopra la curva in Matplotlib\" width=\"440\" height=\"284\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 4: riempire l&#8217;area tra due linee verticali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come utilizzare la funzione <strong>fill_betweenx()<\/strong> per riempire l&#8217;area tra due linee verticali:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#define x and y values\n<\/span>x = np. <span style=\"color: #3366ff;\">arange<\/span> (0,10,0.1)\ny = np. <span style=\"color: #3366ff;\">arange<\/span> (10,20,0.1)\n\n<span style=\"color: #008080;\">#create plot of values\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x,y)\n\n<span style=\"color: #008080;\">#fill in area between the two lines\n<\/span>plt. <span style=\"color: #3366ff;\">fill_betweenx<\/span> (y, 2, 4, color=' <span style=\"color: #008000;\">red<\/span> ', alpha= <span style=\"color: #008000;\">.5<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11812 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/remplirentre5.png\" alt=\"Riempi tra due righe in matplotlib in Python\" width=\"494\" height=\"317\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><strong>Correlati:<\/strong><\/span> <a href=\"https:\/\/statorials.org\/it\/matplotlib-curva-liscia\/\" target=\"_blank\" rel=\"noopener noreferrer\">come tracciare una curva uniforme in Matplotlib<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Puoi facilmente riempire l&#8217;area tra i valori in un grafico Matplotlib utilizzando le seguenti funzioni: fill_between() : riempie l&#8217;area tra due curve orizzontali. fill_betweenx() : riempie l&#8217;area tra due curve verticali. Questo tutorial fornisce esempi di come utilizzare ciascuna di queste funzioni nella pratica. Esempio 1: riempire l&#8217;area tra due linee orizzontali Il codice seguente [&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 riempire le aree tra le righe in Matplotlib<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come riempire le aree tra due linee 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\/riempimento-matplotlib-tra\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come riempire le aree tra le righe in Matplotlib\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come riempire le aree tra due linee in Matplotlib, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T08:47:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/remplirentre1.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\/riempimento-matplotlib-tra\/\",\"url\":\"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/\",\"name\":\"Come riempire le aree tra le righe in Matplotlib\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-27T08:47:37+00:00\",\"dateModified\":\"2023-07-27T08:47:37+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come riempire le aree tra due linee in Matplotlib, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come riempire le aree tra le righe in 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 riempire le aree tra le righe in Matplotlib","description":"Questo tutorial spiega come riempire le aree tra due linee 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\/riempimento-matplotlib-tra\/","og_locale":"it_IT","og_type":"article","og_title":"Come riempire le aree tra le righe in Matplotlib","og_description":"Questo tutorial spiega come riempire le aree tra due linee in Matplotlib, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/","og_site_name":"Statorials","article_published_time":"2023-07-27T08:47:37+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/remplirentre1.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\/riempimento-matplotlib-tra\/","url":"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/","name":"Come riempire le aree tra le righe in Matplotlib","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-27T08:47:37+00:00","dateModified":"2023-07-27T08:47:37+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come riempire le aree tra due linee in Matplotlib, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/riempimento-matplotlib-tra\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come riempire le aree tra le righe in 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\/1188"}],"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=1188"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1188\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}