{"id":3010,"date":"2023-07-19T16:01:02","date_gmt":"2023-07-19T16:01:02","guid":{"rendered":"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/"},"modified":"2023-07-19T16:01:02","modified_gmt":"2023-07-19T16:01:02","slug":"titolo-della-legenda-matplotlib","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/","title":{"rendered":"Come aggiungere un titolo alla legenda matplotlib (con esempi)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Per impostazione predefinita, le legende della trama Matplotlib non includono un titolo.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Tuttavia, puoi utilizzare la seguente sintassi di base per aggiungere un titolo a una didascalia:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>plt. <span style=\"color: #3366ff;\">legend<\/span> (title=' <span style=\"color: #ff0000;\">this is my title<\/span> ')<\/strong>\n<\/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 1: aggiungi un titolo alla legenda Matplotlib<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come creare un grafico Matplotlib con pi\u00f9 righe e una legenda:<\/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<span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#createdata\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">points<\/span> ': [11, 17, 16, 18, 22, 25, 26, 24, 29],\n                   ' <span style=\"color: #ff0000;\">assists<\/span> ': [5, 7, 7, 9, 12, 9, 9, 4, 8]})\n\n<span style=\"color: #008080;\">#add lines to plot\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (df[' <span style=\"color: #ff0000;\">points<\/span> '], label=' <span style=\"color: #ff0000;\">Points<\/span> ')\nplt. <span style=\"color: #3366ff;\">plot<\/span> (df[' <span style=\"color: #ff0000;\">assists<\/span> '], label=' <span style=\"color: #ff0000;\">Assists<\/span> ')\n\n<span style=\"color: #008080;\">#add legend\n<\/span>plt. <span style=\"color: #3366ff;\">legend<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25959 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/legendetitre1.jpg\" alt=\"\" width=\"522\" height=\"349\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che la didascalia non ha titolo.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Per aggiungerne uno, possiamo semplicemente utilizzare l&#8217;argomento <strong>titolo<\/strong> nella funzione <strong>plt.legend()<\/strong> :<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#add title to legend\n<\/span>plt. <span style=\"color: #3366ff;\">legend<\/span> (title=' <span style=\"color: #ff0000;\">Metric<\/span> ')<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-25960 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/legendetitre2.jpg\" alt=\"aggiungi il titolo della legenda alla trama Matplotlib\" width=\"527\" height=\"359\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Per modificare la dimensione del carattere del titolo della didascalia, utilizza l&#8217;argomento <strong>title_fontsize<\/strong> :<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : la dimensione predefinita del carattere \u00e8 10.<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#add title to legend with increased font size\n<\/span>plt. <span style=\"color: #3366ff;\">legend<\/span> (title=' <span style=\"color: #ff0000;\">Metric<\/span> ', title_fontsize= <span style=\"color: #008000;\">25<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25961 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/legendetitre3.jpg\" alt=\"\" width=\"543\" height=\"351\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che la dimensione del carattere della didascalia ora \u00e8 molto pi\u00f9 grande.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Puoi anche utilizzare l&#8217;argomento <strong>fontsize<\/strong> per aumentare la dimensione del carattere delle etichette nella legenda:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#add title to legend with increased title and label font size\n<\/span>plt. <span style=\"color: #3366ff;\">legend<\/span> (title=' <span style=\"color: #ff0000;\">Metric<\/span> ', title_fontsize= <span style=\"color: #008000;\">25<\/span> , fontsize= <span style=\"color: #008000;\">15<\/span> )<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25962 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/legendetitre4.jpg\" alt=\"\" width=\"544\" height=\"365\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che le etichette nella legenda ora sono molto pi\u00f9 grandi.<\/span><\/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 operazioni comuni in Matplotlib:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/dimensione-del-carattere-della-legenda-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Come modificare la dimensione del carattere della legenda in Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/ordine-delle-leggende-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Come modificare l&#8217;ordine degli elementi nella legenda Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/posizione-della-legenda-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Come cambiare la posizione di una legenda in Matplotlib<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Per impostazione predefinita, le legende della trama Matplotlib non includono un titolo. Tuttavia, puoi utilizzare la seguente sintassi di base per aggiungere un titolo a una didascalia: plt. legend (title=&#8217; this is my title &#8216;) L&#8217;esempio seguente mostra come utilizzare questa sintassi nella pratica. Esempio 1: aggiungi un titolo alla legenda Matplotlib 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 aggiungere un titolo alla legenda Matplotlib (con esempi) \u2013 Statoriale<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come aggiungere un titolo a una legenda 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\/titolo-della-legenda-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come aggiungere un titolo alla legenda Matplotlib (con esempi) \u2013 Statoriale\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come aggiungere un titolo a una legenda in Matplotlib, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-19T16:01:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/legendetitre1.jpg\" \/>\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=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/\",\"url\":\"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/\",\"name\":\"Come aggiungere un titolo alla legenda Matplotlib (con esempi) \u2013 Statoriale\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-19T16:01:02+00:00\",\"dateModified\":\"2023-07-19T16:01:02+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come aggiungere un titolo a una legenda in Matplotlib, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come aggiungere un titolo alla legenda matplotlib (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 aggiungere un titolo alla legenda Matplotlib (con esempi) \u2013 Statoriale","description":"Questo tutorial spiega come aggiungere un titolo a una legenda 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\/titolo-della-legenda-matplotlib\/","og_locale":"it_IT","og_type":"article","og_title":"Come aggiungere un titolo alla legenda Matplotlib (con esempi) \u2013 Statoriale","og_description":"Questo tutorial spiega come aggiungere un titolo a una legenda in Matplotlib, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/","og_site_name":"Statorials","article_published_time":"2023-07-19T16:01:02+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/legendetitre1.jpg"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/","url":"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/","name":"Come aggiungere un titolo alla legenda Matplotlib (con esempi) \u2013 Statoriale","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-19T16:01:02+00:00","dateModified":"2023-07-19T16:01:02+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come aggiungere un titolo a una legenda in Matplotlib, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/titolo-della-legenda-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come aggiungere un titolo alla legenda matplotlib (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\/3010"}],"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=3010"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3010\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}