{"id":3023,"date":"2023-07-19T14:30:32","date_gmt":"2023-07-19T14:30:32","guid":{"rendered":"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/"},"modified":"2023-07-19T14:30:32","modified_gmt":"2023-07-19T14:30:32","slug":"r-varios-graficos-no-mesmo-grafico","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/","title":{"rendered":"Como tra\u00e7ar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em r (3 exemplos)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Voc\u00ea pode usar os seguintes m\u00e9todos para desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 1: desenhe v\u00e1rias linhas no mesmo gr\u00e1fico<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#plot first line<\/span>\nplot(x, y1, type=' <span style=\"color: #ff0000;\">l<\/span> ')\n\n<span style=\"color: #008080;\">#add second line to plot\n<\/span>lines(x, y2)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 2: criar v\u00e1rios caminhos lado a lado<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define plotting area as one row and two columns\n<span style=\"color: #000000;\">by(mfrow = c(1, 2))\n<\/span>\n#create first plot\n<span style=\"color: #000000;\">plot(x, y1, type=' <span style=\"color: #ff0000;\">l<\/span> ')\n<\/span>\n#create second plot\n<span style=\"color: #000000;\">plot(x, y2, type=' <span style=\"color: #ff0000;\">l<\/span> ')\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 3: criar v\u00e1rios gr\u00e1ficos empilhados verticalmente<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define plotting area as two rows and one column\n<span style=\"color: #000000;\">by(mfrow = c(2, 1))<\/span>\n<span style=\"color: #000000;\">  \n<span style=\"color: #008080;\">#create first plot\n<\/span>plot(x, y1, type=' <span style=\"color: #ff0000;\">l<\/span> ')\n\n<span style=\"color: #008080;\">#create second plot\n<\/span>plot(x, y2, type=' <span style=\"color: #ff0000;\">l<\/span> ')<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como usar cada m\u00e9todo na pr\u00e1tica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 1: Desenhando M\u00faltiplas Linhas no Mesmo Gr\u00e1fico<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como desenhar duas linhas no mesmo gr\u00e1fico em R:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define data to plot\n<span style=\"color: #000000;\">x &lt;- 1:10\ny1 &lt;- c(2, 4, 4, 5, 7, 6, 5, 8, 12, 19)\ny2 &lt;- c(2, 2, 3, 4, 4, 6, 5, 9, 10, 13)\n\n<span style=\"color: #008080;\">#plot first line\n<\/span>plot(x, y1, type=' <span style=\"color: #ff0000;\">l<\/span> ', col=' <span style=\"color: #ff0000;\">red<\/span> ', xlab=' <span style=\"color: #ff0000;\">x<\/span> ', ylab=' <span style=\"color: #ff0000;\">y<\/span> ')\n\n<span style=\"color: #008080;\">#add second line to plot\n<\/span>lines(x, y2, col=' <span style=\"color: #ff0000;\">blue<\/span> ')\n<\/span><\/span><\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-26030\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/meme-graphique1.jpg\" alt=\"R tra\u00e7a v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico\" width=\"445\" height=\"408\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 2: Crie v\u00e1rios caminhos lado a lado<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como usar o argumento <strong>par()<\/strong> para tra\u00e7ar v\u00e1rios gr\u00e1ficos lado a lado:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define data to plot\n<span style=\"color: #000000;\">x &lt;- 1:10\ny1 &lt;- c(2, 4, 4, 5, 7, 6, 5, 8, 12, 19)\ny2 &lt;- c(2, 2, 3, 4, 4, 6, 5, 9, 10, 13)<\/span>\n\n#define plotting area as one row and two columns\n<span style=\"color: #000000;\">by(mfrow = c(1, 2))\n\n<span style=\"color: #008080;\">#create first line plot\n<\/span>plot(x, y1, type=' <span style=\"color: #ff0000;\">l<\/span> ', col=' <span style=\"color: #ff0000;\">red<\/span> ')\n\n<span style=\"color: #008080;\">#create second line plot<\/span>\nplot(x, y2, type=' <span style=\"color: #ff0000;\">l<\/span> ', col=' <span style=\"color: #ff0000;\">blue<\/span> ', ylim=c(min(y1), max(y1)))<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-26031 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/meme-graphique2.jpg\" alt=\"\" width=\"442\" height=\"406\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Observe que usamos o argumento <a href=\"https:\/\/statorials.org\/pt\/xlim-ylim-em-r\/\" target=\"_blank\" rel=\"noopener\">ylim()<\/a> no segundo gr\u00e1fico para garantir que ambos os gr\u00e1ficos tivessem os mesmos limites no eixo y.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 3: Crie v\u00e1rios gr\u00e1ficos empilhados verticalmente<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como usar o argumento <strong>par()<\/strong> para tra\u00e7ar v\u00e1rios gr\u00e1ficos empilhados verticalmente:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define data to plot\n<span style=\"color: #000000;\">x &lt;- 1:10\ny1 &lt;- c(2, 4, 4, 5, 7, 6, 5, 8, 12, 19)\ny2 &lt;- c(2, 2, 3, 4, 4, 6, 5, 9, 10, 13)<\/span>\n\n#define plotting area as two rows and one column\n<span style=\"color: #000000;\">par(mfrow = c(2, 1), mar = c(2, 4, 4, 2))\n<span style=\"color: #008080;\">#create first line plot\n<\/span>plot(x, y1, type=' <span style=\"color: #ff0000;\">l<\/span> ', col=' <span style=\"color: #ff0000;\">red<\/span> ')\n\n<span style=\"color: #008080;\">#create second line plot\n<\/span>plot(x, y2, type=' <span style=\"color: #ff0000;\">l<\/span> ', col=' <span style=\"color: #ff0000;\">blue<\/span> ', ylim=c(min(y1), max(y1)))<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-26032 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/meme-graphique3.jpg\" alt=\"\" width=\"458\" height=\"433\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Observe que usamos o argumento <strong>mar<\/strong> para especificar as margens (inferior, esquerda, superior, direita) da \u00e1rea do gr\u00e1fico.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota:<\/strong> O padr\u00e3o \u00e9 mar = c(5,1, 4,1, 4,1, 2,1)<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Os tutoriais a seguir explicam como realizar outras tarefas comuns em R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/plotar-multiplas-colunas-em-r\/\" target=\"_blank\" rel=\"noopener\">Como plotar m\u00faltiplas colunas em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/lenda-fora-do-enredo-r\/\" target=\"_blank\" rel=\"noopener\">Como desenhar uma legenda fora de um gr\u00e1fico em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/log-grafico-de-log-em-r\/\" target=\"_blank\" rel=\"noopener\">Como criar um gr\u00e1fico log-log em R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar os seguintes m\u00e9todos para desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R: M\u00e9todo 1: desenhe v\u00e1rias linhas no mesmo gr\u00e1fico #plot first line plot(x, y1, type=&#8217; l &#8216;) #add second line to plot lines(x, y2) M\u00e9todo 2: criar v\u00e1rios caminhos lado a lado #define plotting area as one row and two columns [&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":[],"class_list":["post-3023","post","type-post","status-publish","format-standard","hentry","category-guia"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Como plotar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R (3 exemplos) - Statorials<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R, com v\u00e1rios exemplos.\" \/>\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\/pt\/r-varios-graficos-no-mesmo-grafico\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como plotar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R (3 exemplos) - Statorials\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-19T14:30:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/meme-graphique1.jpg\" \/>\n<meta name=\"author\" content=\"Dr. benjamim anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. benjamim anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/\",\"url\":\"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/\",\"name\":\"Como plotar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R (3 exemplos) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-19T14:30:32+00:00\",\"dateModified\":\"2023-07-19T14:30:32+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como tra\u00e7ar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em r (3 exemplos)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/pt\/#website\",\"url\":\"https:\/\/statorials.org\/pt\/\",\"name\":\"Statorials\",\"description\":\"O seu guia para a literacia estat\u00edstica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/pt\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\",\"name\":\"Dr. benjamim anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. benjamim anderson\"},\"description\":\"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais\",\"sameAs\":[\"https:\/\/statorials.org\/pt\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Como plotar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R (3 exemplos) - Statorials","description":"Este tutorial explica como desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R, com v\u00e1rios exemplos.","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\/pt\/r-varios-graficos-no-mesmo-grafico\/","og_locale":"pt_PT","og_type":"article","og_title":"Como plotar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R (3 exemplos) - Statorials","og_description":"Este tutorial explica como desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/","og_site_name":"Statorials","article_published_time":"2023-07-19T14:30:32+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/meme-graphique1.jpg"}],"author":"Dr. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/","url":"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/","name":"Como plotar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R (3 exemplos) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-19T14:30:32+00:00","dateModified":"2023-07-19T14:30:32+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como desenhar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em R, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/r-varios-graficos-no-mesmo-grafico\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como tra\u00e7ar v\u00e1rios gr\u00e1ficos no mesmo gr\u00e1fico em r (3 exemplos)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/pt\/#website","url":"https:\/\/statorials.org\/pt\/","name":"Statorials","description":"O seu guia para a literacia estat\u00edstica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/pt\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-PT"},{"@type":"Person","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666","name":"Dr. benjamim anderson","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr. benjamim anderson"},"description":"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais","sameAs":["https:\/\/statorials.org\/pt"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/3023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/comments?post=3023"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/3023\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=3023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=3023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=3023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}