{"id":1190,"date":"2023-07-27T08:38:01","date_gmt":"2023-07-27T08:38:01","guid":{"rendered":"https:\/\/statorials.org\/it\/freccia-matplotlib\/"},"modified":"2023-07-27T08:38:01","modified_gmt":"2023-07-27T08:38:01","slug":"freccia-matplotlib","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/freccia-matplotlib\/","title":{"rendered":"Come disegnare frecce in matplotlib"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Per disegnare frecce in Matplotlib, puoi utilizzare la<\/span> funzione <a href=\"https:\/\/matplotlib.org\/api\/_as_gen\/matplotlib.pyplot.arrow.html\" target=\"_blank\" rel=\"noopener noreferrer\">matplotlib.pyplot.arrow<\/a> <span style=\"color: #000000;\">, che utilizza la seguente sintassi:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>matplotlib.pyplot.arrow(x, y, dx, dy)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Oro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>x, y:<\/strong> le coordinate xey della base della freccia<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>dx, dy:<\/strong> la lunghezza della freccia nelle direzioni xey<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Questo tutorial fornisce diversi esempi di utilizzo pratico di questa funzione.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: disegna una singola freccia<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come disegnare una singola freccia su un grafico Matplotlib:<\/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\n<span style=\"color: #008080;\">#define two arrays for plotting\n<\/span>A = [3, 5, 5, 6, 7, 8]\nB = [12, 14, 17, 20, 22, 27]\n\n<span style=\"color: #008080;\">#create scatterplot, specifying marker size to be 40\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (A, B, s= <span style=\"color: #008000;\">40<\/span> )\n\n<span style=\"color: #008080;\">#add arrow to plot\n<\/span>plt. <span style=\"color: #3366ff;\">arrow<\/span> (x= <span style=\"color: #008000;\">4<\/span> , y= <span style=\"color: #008000;\">18<\/span> , dx= <span style=\"color: #008000;\">2<\/span> , dy= <span style=\"color: #008000;\">5<\/span> , width= <span style=\"color: #008000;\">.08<\/span> ) \n  \n<span style=\"color: #008080;\">#displayplot \n<\/span>plt. <span style=\"color: #3366ff;\">show<\/span> ()\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11827 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/fleche1.png\" alt=\"Freccia nel grafico matplotlib\" width=\"409\" height=\"274\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Nota che possiamo impostare <strong>dx=0<\/strong> per creare una freccia verticale e <strong>dy=0<\/strong> per creare una freccia orizzontale.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, ecco come creare una freccia verticale:<\/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\n<span style=\"color: #008080;\">#define two arrays for plotting\n<\/span>A = [3, 5, 5, 6, 7, 8]\nB = [12, 14, 17, 20, 22, 27]\n\n<span style=\"color: #008080;\">#create scatterplot, specifying marker size to be 40\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (A, B, s= <span style=\"color: #008000;\">40<\/span> )\n\n<span style=\"color: #008080;\">#add arrow to plot\n<\/span>plt. <span style=\"color: #3366ff;\">arrow<\/span> (x= <span style=\"color: #008000;\">4<\/span> , y= <span style=\"color: #008000;\">18<\/span> , dx= <span style=\"color: #008000;\">0<\/span> , dy= <span style=\"color: #008000;\">5<\/span> , width= <span style=\"color: #008000;\">.08<\/span> ) \n  \n<span style=\"color: #008080;\">#displayplot \n<\/span>plt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11828 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/fleche2.png\" alt=\"Freccia verticale in matplotlib\" width=\"407\" height=\"263\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: styling di una freccia<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Per impostazione predefinita, una freccia in Matplotlib \u00e8 blu con bordi neri ma possiamo facilmente modificarla utilizzando gli argomenti <strong>facecolor<\/strong> e <strong>edgecolor<\/strong> :<\/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\n<span style=\"color: #008080;\">#define two arrays for plotting\n<\/span>A = [3, 5, 5, 6, 7, 8]\nB = [12, 14, 17, 20, 22, 27]\n\n<span style=\"color: #008080;\">#create scatterplot, specifying marker size to be 40\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (A, B, s= <span style=\"color: #008000;\">40<\/span> )\n\n<span style=\"color: #008080;\">#add arrow to plot\n<\/span>plt. <span style=\"color: #3366ff;\">arrow<\/span> (x= <span style=\"color: #008000;\">4<\/span> , y= <span style=\"color: #008000;\">18<\/span> , dx= <span style=\"color: #008000;\">0<\/span> , dy= <span style=\"color: #008000;\">5<\/span> , width= <span style=\"color: #008000;\">.08 <span style=\"color: #000000;\">, facecolor=<\/span> 'red' <span style=\"color: #000000;\">, edgecolor=<\/span> 'none'<\/span> ) \n  \n<span style=\"color: #008080;\">#displayplot \n<\/span>plt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11829 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/fleche3.png\" alt=\"Freccia con colore personalizzato in matplotlib\" width=\"409\" height=\"276\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Puoi trovare un elenco completo delle propriet\u00e0 di stile che possono essere applicate alle frecce <a href=\"https:\/\/matplotlib.org\/api\/_as_gen\/matplotlib.pyplot.arrow.html\" target=\"_blank\" rel=\"noopener noreferrer\">qui<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 3: aggiungere annotazioni alle frecce<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come aggiungere un&#8217;annotazione sotto una freccia su un grafico Matplotlib:<\/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\n<span style=\"color: #008080;\">#define two arrays for plotting\n<\/span>A = [3, 5, 5, 6, 7, 8]\nB = [12, 14, 17, 20, 22, 27]\n\n<span style=\"color: #008080;\">#create scatterplot, specifying marker size to be 40\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (A, B, s= <span style=\"color: #008000;\">40<\/span> )\n\n<span style=\"color: #008080;\">#add arrow to plot\n<\/span>plt. <span style=\"color: #3366ff;\">arrow<\/span> (x= <span style=\"color: #008000;\">4<\/span> , y= <span style=\"color: #008000;\">18<\/span> , dx= <span style=\"color: #008000;\">0<\/span> , dy= <span style=\"color: #008000;\">5<\/span> , width= <span style=\"color: #008000;\">.08<\/span> ) \n\n<span style=\"color: #008080;\">#add annotation\n<\/span>plt. <span style=\"color: #3366ff;\">annotate<\/span> (' <span style=\"color: #008000;\">General direction<\/span> ', xy = (3.4, 17))\n  \n<span style=\"color: #008080;\">#displayplot \n<\/span>plt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11830 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/fleche4.png\" alt=\"Freccia con annotazione in matplotlib\" width=\"395\" height=\"263\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/cerchio-matplotlib\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come tracciare cerchi in Matplotlib (con esempi)<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/matplotlib-rettangolare\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come disegnare rettangoli in Matplotlib (con esempi)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Per disegnare frecce in Matplotlib, puoi utilizzare la funzione matplotlib.pyplot.arrow , che utilizza la seguente sintassi: matplotlib.pyplot.arrow(x, y, dx, dy) Oro: x, y: le coordinate xey della base della freccia dx, dy: la lunghezza della freccia nelle direzioni xey Questo tutorial fornisce diversi esempi di utilizzo pratico di questa funzione. Esempio 1: disegna una singola [&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 disegnare le frecce in Matplotlib \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come disegnare frecce sui grafici 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\/freccia-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come disegnare le frecce in Matplotlib \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come disegnare frecce sui grafici Matplotlib, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/freccia-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T08:38:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/fleche1.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\/freccia-matplotlib\/\",\"url\":\"https:\/\/statorials.org\/it\/freccia-matplotlib\/\",\"name\":\"Come disegnare le frecce in Matplotlib \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-27T08:38:01+00:00\",\"dateModified\":\"2023-07-27T08:38:01+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come disegnare frecce sui grafici Matplotlib, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/freccia-matplotlib\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/freccia-matplotlib\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/freccia-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come disegnare frecce 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 disegnare le frecce in Matplotlib \u2013 Statorials","description":"Questo tutorial spiega come disegnare frecce sui grafici 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\/freccia-matplotlib\/","og_locale":"it_IT","og_type":"article","og_title":"Come disegnare le frecce in Matplotlib \u2013 Statorials","og_description":"Questo tutorial spiega come disegnare frecce sui grafici Matplotlib, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/freccia-matplotlib\/","og_site_name":"Statorials","article_published_time":"2023-07-27T08:38:01+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/fleche1.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\/freccia-matplotlib\/","url":"https:\/\/statorials.org\/it\/freccia-matplotlib\/","name":"Come disegnare le frecce in Matplotlib \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-27T08:38:01+00:00","dateModified":"2023-07-27T08:38:01+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come disegnare frecce sui grafici Matplotlib, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/freccia-matplotlib\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/freccia-matplotlib\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/freccia-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come disegnare frecce 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\/1190"}],"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=1190"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1190\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}