{"id":1000,"date":"2023-07-28T01:14:49","date_gmt":"2023-07-28T01:14:49","guid":{"rendered":"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/"},"modified":"2023-07-28T01:14:49","modified_gmt":"2023-07-28T01:14:49","slug":"matplotlib-annota-il-grafico-a-dispersione","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/","title":{"rendered":"Come annotare i grafici a dispersione matplotlib"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi di base per annotare i grafici a dispersione in Matplotlib:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#add 'my text' at (x, y) coordinates = (6, 9.5)<\/span>\nplt. <span style=\"color: #3366ff;\">text<\/span> (6, 9.5, ' <span style=\"color: #008000;\">my text<\/span> ')<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Gli esempi seguenti mostrano come utilizzare questa sintassi nella pratica.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Crea una nuvola di punti di base<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come creare un grafico a dispersione di base utilizzando Matplotlib:<\/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;\">#createdata<\/span>\nx = [3, 6, 8, 12, 14]\ny = [4, 9, 14, 12, 9]\n\n<span style=\"color: #008080;\">#create scatterplot\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (x,y)\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10367 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/scatterannoter1.png\" alt=\"\" width=\"400\" height=\"270\" srcset=\"\" sizes=\"\"><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Annotare un singolo punto<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Possiamo usare il seguente codice per aggiungere un&#8217;annotazione a un singolo punto sulla trama:<\/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;\">#create data<\/span>\nx = [3, 6, 8, 12, 14]\ny = [4, 9, 14, 12, 9]\n\n<span style=\"color: #008080;\">#create scatterplot\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (x,y)\n\n<span style=\"color: #008080;\">#add text 'Here' at (x, y) coordinates = (6, 9.5)<\/span>\nplt. <span style=\"color: #3366ff;\">text<\/span> (6, 9.5, ' <span style=\"color: #008000;\">Here<\/span> ')\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10368 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/scatterannoter2.png\" alt=\"Grafico a dispersione con annotazione in Matplotlib\" width=\"410\" height=\"284\" srcset=\"\" sizes=\"\"><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Annota pi\u00f9 punti<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Possiamo utilizzare il seguente codice per aggiungere annotazioni a pi\u00f9 punti sulla trama:<\/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;\">#create data<\/span>\nx = [3, 6, 8, 12, 14]\ny = [4, 9, 14, 12, 9]\n\n<span style=\"color: #008080;\">#create scatterplot\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (x,y)\n\n<span style=\"color: #008080;\">#add text to certain points<\/span>\nplt. <span style=\"color: #3366ff;\">text<\/span> (3, 4.5, ' <span style=\"color: #008000;\">This<\/span> ')\nplt. <span style=\"color: #3366ff;\">text<\/span> (6, 9.5, ' <span style=\"color: #008000;\">That<\/span> ')\nplt. <span style=\"color: #3366ff;\">text<\/span> (8.2, 14, ' <span style=\"color: #008000;\">Those<\/span> ')\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10369 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/scatterannotate3.png\" alt=\"Annota pi\u00f9 punti sulla nuvola di punti Matplotlib\" width=\"406\" height=\"275\" srcset=\"\" sizes=\"\"><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Annota tutti i punti<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Possiamo usare il seguente codice per aggiungere annotazioni a ciascun punto della trama:<\/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;\">#createdata<\/span>\nx = [3, 6, 8, 12, 14]\ny = [4, 9, 14, 12, 9]\nlabs = ['A', 'B', 'C', 'D', 'E']\n\n<span style=\"color: #008080;\">#create scatterplot<\/span>\nplt. <span style=\"color: #3366ff;\">scatter<\/span> (x,y)\n\n<span style=\"color: #008080;\">#use for loop to add annotations to each point in plot<\/span> \n<span style=\"color: #008000;\">for<\/span> i, txt <span style=\"color: #008000;\">in<\/span> enumerate(labs):\n    plt. <span style=\"color: #3366ff;\">annotate<\/span> (txt, (x[ <span style=\"color: #993300;\">i<\/span> ], y[ <span style=\"color: #993300;\">i<\/span> ]))<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10370 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/scatterannoter4.png\" alt=\"Annotare la nuvola di punti Matplotlib\" width=\"469\" height=\"319\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Per impostazione predefinita, le annotazioni vengono posizionate direttamente sopra i punti nella nuvola di punti e la dimensione del carattere predefinita \u00e8 10.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come regolare queste due impostazioni in modo che le annotazioni siano leggermente a destra dei punti e la dimensione del carattere sia leggermente pi\u00f9 grande:<\/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;\">#create data<\/span>\nx = [3, 6, 8, 12, 14]\ny = [4, 9, 14, 12, 9]\nlabs = ['A', 'B', 'C', 'D', 'E']\n\n<span style=\"color: #008080;\">#create scatterplot<\/span>\nplt. <span style=\"color: #3366ff;\">scatter<\/span> (x,y)\n\n<span style=\"color: #008080;\">#use for loop to add annotations to each point in plot<\/span> \n<span style=\"color: #008000;\">for<\/span> i, txt <span style=\"color: #008000;\">in<\/span> enumerate(labs):\n    plt. <span style=\"color: #3366ff;\">annotate<\/span> (txt, (x[ <span style=\"color: #993300;\">i<\/span> ]+.25, y[ <span style=\"color: #993300;\">i<\/span> ]), fontsize=12)<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10371 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/scatterannoter5.png\" alt=\"Matplotlib annota ogni punto della trama\" width=\"410\" height=\"276\" srcset=\"\" sizes=\"\"><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altre attivit\u00e0 comuni in Matplotlib:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/legenda-della-nuvola-di-punti-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Come aggiungere la legenda al grafico a dispersione in Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/matplotlib-colore-in-base-al-valore-scatterplot\/\" target=\"_blank\" rel=\"noopener\">Come colorare un grafico a dispersione in base al valore in Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/linea-media-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Come aggiungere una linea media ai grafici in Matplotlib<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi di base per annotare i grafici a dispersione in Matplotlib: #add &#8216;my text&#8217; at (x, y) coordinates = (6, 9.5) plt. text (6, 9.5, &#8216; my text &#8216;) Gli esempi seguenti mostrano come utilizzare questa sintassi nella pratica. Crea una nuvola di punti di base Il codice seguente mostra [&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 annotare i grafici a dispersione Matplotlib - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come aggiungere annotazioni ai grafici a dispersione 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\/matplotlib-annota-il-grafico-a-dispersione\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come annotare i grafici a dispersione Matplotlib - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come aggiungere annotazioni ai grafici a dispersione Matplotlib, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T01:14:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/scatterannoter1.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\/matplotlib-annota-il-grafico-a-dispersione\/\",\"url\":\"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/\",\"name\":\"Come annotare i grafici a dispersione Matplotlib - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-28T01:14:49+00:00\",\"dateModified\":\"2023-07-28T01:14:49+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come aggiungere annotazioni ai grafici a dispersione Matplotlib, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come annotare i grafici a dispersione 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 annotare i grafici a dispersione Matplotlib - Statorials","description":"Questo tutorial spiega come aggiungere annotazioni ai grafici a dispersione 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\/matplotlib-annota-il-grafico-a-dispersione\/","og_locale":"it_IT","og_type":"article","og_title":"Come annotare i grafici a dispersione Matplotlib - Statorials","og_description":"Questo tutorial spiega come aggiungere annotazioni ai grafici a dispersione Matplotlib, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/","og_site_name":"Statorials","article_published_time":"2023-07-28T01:14:49+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/scatterannoter1.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\/matplotlib-annota-il-grafico-a-dispersione\/","url":"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/","name":"Come annotare i grafici a dispersione Matplotlib - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-28T01:14:49+00:00","dateModified":"2023-07-28T01:14:49+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come aggiungere annotazioni ai grafici a dispersione Matplotlib, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/matplotlib-annota-il-grafico-a-dispersione\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come annotare i grafici a dispersione 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\/1000"}],"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=1000"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1000\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}