{"id":1650,"date":"2023-07-25T12:44:47","date_gmt":"2023-07-25T12:44:47","guid":{"rendered":"https:\/\/statorials.org\/it\/log-log-tracciato-python\/"},"modified":"2023-07-25T12:44:47","modified_gmt":"2023-07-25T12:44:47","slug":"log-log-tracciato-python","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/log-log-tracciato-python\/","title":{"rendered":"Come creare un grafico log-log in python"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un <strong>grafico log-log<\/strong> \u00e8 un grafico che utilizza scale logaritmiche sia sull&#8217;asse x che sull&#8217;asse y.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tipo di grafico \u00e8 utile per visualizzare due variabili quando la vera relazione tra loro segue un qualche tipo di legge di potere.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial spiega come creare un grafico log-log in Python.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Come creare un grafico log-log in Python<\/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<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;\">#createDataFrame\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">x<\/span> ': [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,\n                         14, 15, 16, 17, 18, 19, 20, 21, 22],\n                   ' <span style=\"color: #ff0000;\">y<\/span> ': [3, 4, 5, 7, 9, 13, 15, 19, 23, 24, 29,\n                         38, 40, 50, 56, 59, 70, 89, 104, 130]})\n\n<span style=\"color: #008080;\">#create scatterplot\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (df. <span style=\"color: #3366ff;\">x<\/span> , df. <span style=\"color: #3366ff;\">y<\/span> )\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-16266 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loglogpython1.png\" alt=\"\" width=\"535\" height=\"369\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">\u00c8 chiaro che la relazione tra <em>xey<\/em> segue una legge <em>di<\/em> potenza.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come utilizzare <strong>numpy.log()<\/strong> per eseguire una trasformazione log sulle due variabili e creare un grafico log-log per visualizzare la relazione tra loro:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np<\/span>\n\n#perform log transformation on both x and y\n<\/span>xlog = np. <span style=\"color: #3366ff;\">log<\/span> ( <span style=\"color: #3366ff;\">df.x<\/span> )\nylog = np. <span style=\"color: #3366ff;\">log<\/span> ( <span style=\"color: #3366ff;\">df.y<\/span> )\n\n<span style=\"color: #008080;\">#create log-log plot\n<\/span>plt. <span style=\"color: #3366ff;\">scatter<\/span> (xlog, ylog)\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-16267 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loglogpython2.png\" alt=\"\" width=\"530\" height=\"372\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">L&#8217;asse x mostra il logaritmo di x e l&#8217;asse y mostra il logaritmo di y.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Si noti come la relazione tra log(x) e log(y) sia molto pi\u00f9 lineare rispetto al grafico precedente.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Sentiti libero di aggiungere un titolo e le etichette degli assi per rendere la trama pi\u00f9 facile da interpretare:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create log-log plot with labels\n<span style=\"color: #000000;\">plt. <span style=\"color: #3366ff;\">scatter<\/span> (xlog, ylog, color=' <span style=\"color: #ff0000;\">purple<\/span> ')\nplt. <span style=\"color: #3366ff;\">xlabel<\/span> (' <span style=\"color: #ff0000;\">Log(x)<\/span> ')\nplt. <span style=\"color: #3366ff;\">ylabel<\/span> (' <span style=\"color: #ff0000;\">Log(y)<\/span> ')\nplt. <span style=\"color: #3366ff;\">title<\/span> (' <span style=\"color: #ff0000;\">Log-Log Plot<\/span> ')<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-16268 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loglogpython3.png\" alt=\"\" width=\"534\" height=\"390\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni inoltre presente che puoi creare un grafico a linee anzich\u00e9 un grafico a dispersione semplicemente utilizzando <strong>plt.plot()<\/strong> come segue:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create log-log line plot\n<span style=\"color: #000000;\">plt. <span style=\"color: #3366ff;\">plot<\/span> (xlog, ylog, color=' <span style=\"color: #ff0000;\">purple<\/span> ')\nplt. <span style=\"color: #3366ff;\">xlabel<\/span> (' <span style=\"color: #ff0000;\">Log(x)<\/span> ')\nplt. <span style=\"color: #3366ff;\">ylabel<\/span> (' <span style=\"color: #ff0000;\">Log(y)<\/span> ')\nplt. <span style=\"color: #3366ff;\">title<\/span> (' <span style=\"color: #ff0000;\">Log-Log Plot<\/span> ')<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-16274\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loglogpython4.png\" alt=\"Grafico log-log in Python\" width=\"537\" height=\"382\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/log-log-grafico-in-r\/\" target=\"_blank\" rel=\"noopener\">Come creare un grafico log-log in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/registro-registro-tracciato-excel\/\" target=\"_blank\" rel=\"noopener\">Come creare un grafico log-log in Excel<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un grafico log-log \u00e8 un grafico che utilizza scale logaritmiche sia sull&#8217;asse x che sull&#8217;asse y. Questo tipo di grafico \u00e8 utile per visualizzare due variabili quando la vera relazione tra loro segue un qualche tipo di legge di potere. Questo tutorial spiega come creare un grafico log-log in Python. Come creare un grafico log-log [&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 un grafico log-log in Python<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come creare un grafico log-log in Python, 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\/log-log-tracciato-python\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come creare un grafico log-log in Python\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come creare un grafico log-log in Python, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/log-log-tracciato-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T12:44:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loglogpython1.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\/log-log-tracciato-python\/\",\"url\":\"https:\/\/statorials.org\/it\/log-log-tracciato-python\/\",\"name\":\"Come creare un grafico log-log in Python\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-25T12:44:47+00:00\",\"dateModified\":\"2023-07-25T12:44:47+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come creare un grafico log-log in Python, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/log-log-tracciato-python\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/log-log-tracciato-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/log-log-tracciato-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come creare un grafico log-log in python\"}]},{\"@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 un grafico log-log in Python","description":"Questo tutorial spiega come creare un grafico log-log in Python, 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\/log-log-tracciato-python\/","og_locale":"it_IT","og_type":"article","og_title":"Come creare un grafico log-log in Python","og_description":"Questo tutorial spiega come creare un grafico log-log in Python, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/log-log-tracciato-python\/","og_site_name":"Statorials","article_published_time":"2023-07-25T12:44:47+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/loglogpython1.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\/log-log-tracciato-python\/","url":"https:\/\/statorials.org\/it\/log-log-tracciato-python\/","name":"Come creare un grafico log-log in Python","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-25T12:44:47+00:00","dateModified":"2023-07-25T12:44:47+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come creare un grafico log-log in Python, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/log-log-tracciato-python\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/log-log-tracciato-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/log-log-tracciato-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come creare un grafico log-log in python"}]},{"@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\/1650"}],"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=1650"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1650\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}