{"id":3598,"date":"2023-07-16T15:26:29","date_gmt":"2023-07-16T15:26:29","guid":{"rendered":"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/"},"modified":"2023-07-16T15:26:29","modified_gmt":"2023-07-16T15:26:29","slug":"sotto-il-titolo-ggplot","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/","title":{"rendered":"Come aggiungere un sottotitolo in ggplot2 (3 esempi)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Puoi utilizzare i seguenti metodi per aggiungere un sottotitolo alle trame in ggplot2:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Metodo 1: aggiungi un sottotitolo<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\">p+\n  labs(title=' <span style=\"color: #ff0000;\">My Title<\/span> ', subtitle=' <span style=\"color: #ff0000;\">My Subtitle<\/span> ')\n<\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 2: aggiungi un sottotitolo su pi\u00f9 righe<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\">p+\n  labs(title=' <span style=\"color: #ff0000;\">My Title<\/span> ', subtitle=' <span style=\"color: #ff0000;\">My Subtitle Line1\\nLine2\\nLine3<\/span> ')<\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 3: aggiungi un sottotitolo con un carattere personalizzato<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\">p+\n  labs(title=' <span style=\"color: #ff0000;\">My Title<\/span> ', subtitle=' <span style=\"color: #ff0000;\">My Subtitle Line1\\nLine2\\nLine3<\/span> ') +\n  theme(plot. <span style=\"color: #3366ff;\">subtitle<\/span> =element_text(size= <span style=\"color: #008000;\">18<\/span> , face=' <span style=\"color: #ff0000;\">italic<\/span> ', color=' <span style=\"color: #ff0000;\">red<\/span> '))<\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">I seguenti esempi mostrano come utilizzare ciascun metodo nella pratica con il seguente frame di dati in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#create data frame<\/span>\ndf &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (hours=c(1, 2, 2, 3, 4, 6, 7, 7, 8, 9),\n                 score=c(76, 77, 75, 79, 84, 88, 85, 94, 95, 90))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n   hours score\n1 1 76\n2 2 77\n3 2 75\n4 3 79\n5 4 84\n6 6 88\n7 7 85\n8 7 94\n9 8 95\n10 9 90\n<\/strong><\/span><\/pre>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 1: aggiungi un sottotitolo in ggplot2<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come aggiungere un sottotitolo di una riga a un grafico a dispersione in ggplot2:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#create scatter plot with subtitle on one line\n<\/span>ggplot(df, aes(x=hours, y=score)) +\n  geom_point(size= <span style=\"color: #008000;\">2<\/span> ) +\n  labs(title=' <span style=\"color: #ff0000;\">Hours Studied vs. Exam Score<\/span> ',\n       subtitle=' <span style=\"color: #ff0000;\">Data Collected in 2022<\/span> ')<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-29652 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-titre1.jpg\" alt=\"\" width=\"513\" height=\"434\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che \u00e8 stato aggiunto un sottotitolo di una riga direttamente sotto il titolo della trama.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 2: aggiungi un sottotitolo su pi\u00f9 righe in ggplot2<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come aggiungere un sottotitolo su pi\u00f9 righe a un grafico a dispersione in ggplot2:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#create scatter plot with subtitle on multiple lines\n<\/span>ggplot(df, aes(x=hours, y=score)) +\n  geom_point(size= <span style=\"color: #008000;\">2<\/span> ) +\n  labs(title=' <span style=\"color: #ff0000;\">Hours Studied vs. Exam Score<\/span> ',\n       subtitle=' <span style=\"color: #ff0000;\">Data Collected in 2022\\nUniversity A Exam Scores<\/span> ')<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-29653\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-titre2-1.jpg\" alt=\"Sottotitolo multilinea in ggplot2\" width=\"532\" height=\"444\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Usando la sintassi di nuova riga ( <strong>\\n<\/strong> ), possiamo creare un sottotitolo su pi\u00f9 righe.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 3: aggiungi un sottotitolo con un carattere personalizzato<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come utilizzare la funzione <strong>theme()<\/strong> in ggplot2 per aggiungere un sottotitolo con dimensione, stile e colore del carattere personalizzati:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#create scatter plot with subtitle that has customized font\n<\/span>ggplot(df, aes(x=hours, y=score)) +\n  geom_point(size= <span style=\"color: #008000;\">2<\/span> ) +\n  labs(title=' <span style=\"color: #ff0000;\">Hours Studied vs. Exam Score<\/span> ',\n       subtitle=' <span style=\"color: #ff0000;\">Data Collected in 2022\\nUniversity A Exam Scores<\/span> ') +\n  theme(plot. <span style=\"color: #3366ff;\">subtitle<\/span> =element_text(size= <span style=\"color: #008000;\">18<\/span> , face=' <span style=\"color: #ff0000;\">italic<\/span> ', color=' <span style=\"color: #ff0000;\">red<\/span> '))<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-29654\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-titre3.jpg\" alt=\"Sottotitolo ggplot2 con carattere personalizzato\" width=\"493\" height=\"416\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che il sottotitolo ora ha una dimensione del carattere pari a 18, uno stile corsivo e un colore rosso.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : puoi anche utilizzare <strong>face=&#8217;bold&#8217;<\/strong> per utilizzare uno stile di carattere in grassetto.<\/span><\/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 ggplot2:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/leggenda-di-ggplot\/\" target=\"_blank\" rel=\"noopener\">Come aggiungere una legenda ai grafici ggplot2<\/a><br \/><a href=\"https:\/\/statorials.org\/it\/dimensione-del-carattere-ggplot\/\" target=\"_blank\" rel=\"noopener\">Come cambiare la dimensione del carattere in ggplot2<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/rimuovi-la-legenda-ggplot2\/\" target=\"_blank\" rel=\"noopener\">Come rimuovere una legenda in ggplot2<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/ruotare-le-etichette-degli-assi-ggplot2\/\" target=\"_blank\" rel=\"noopener\">Come ruotare le etichette degli assi in ggplot2<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Puoi utilizzare i seguenti metodi per aggiungere un sottotitolo alle trame in ggplot2: Metodo 1: aggiungi un sottotitolo p+ labs(title=&#8217; My Title &#8216;, subtitle=&#8217; My Subtitle &#8216;) Metodo 2: aggiungi un sottotitolo su pi\u00f9 righe p+ labs(title=&#8217; My Title &#8216;, subtitle=&#8217; My Subtitle Line1\\nLine2\\nLine3 &#8216;) Metodo 3: aggiungi un sottotitolo con un carattere personalizzato p+ [&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 sottotitolo in ggplot2 (3 esempi) \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come aggiungere e modificare un sottotitolo in ggplot2, 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\/sotto-il-titolo-ggplot\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come aggiungere un sottotitolo in ggplot2 (3 esempi) \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come aggiungere e modificare un sottotitolo in ggplot2, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-16T15:26:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-titre1.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=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/\",\"url\":\"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/\",\"name\":\"Come aggiungere un sottotitolo in ggplot2 (3 esempi) \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-16T15:26:29+00:00\",\"dateModified\":\"2023-07-16T15:26:29+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come aggiungere e modificare un sottotitolo in ggplot2, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come aggiungere un sottotitolo in ggplot2 (3 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 sottotitolo in ggplot2 (3 esempi) \u2013 Statorials","description":"Questo tutorial spiega come aggiungere e modificare un sottotitolo in ggplot2, 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\/sotto-il-titolo-ggplot\/","og_locale":"it_IT","og_type":"article","og_title":"Come aggiungere un sottotitolo in ggplot2 (3 esempi) \u2013 Statorials","og_description":"Questo tutorial spiega come aggiungere e modificare un sottotitolo in ggplot2, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/","og_site_name":"Statorials","article_published_time":"2023-07-16T15:26:29+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sous-titre1.jpg"}],"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\/sotto-il-titolo-ggplot\/","url":"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/","name":"Come aggiungere un sottotitolo in ggplot2 (3 esempi) \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-16T15:26:29+00:00","dateModified":"2023-07-16T15:26:29+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come aggiungere e modificare un sottotitolo in ggplot2, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/sotto-il-titolo-ggplot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come aggiungere un sottotitolo in ggplot2 (3 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\/3598"}],"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=3598"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3598\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}