{"id":1186,"date":"2023-07-27T08:55:04","date_gmt":"2023-07-27T08:55:04","guid":{"rendered":"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/"},"modified":"2023-07-27T08:55:04","modified_gmt":"2023-07-27T08:55:04","slug":"cor-de-fundo-do-matplotlib","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/","title":{"rendered":"Como alterar a cor de fundo no matplotlib (com exemplos)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">A maneira mais f\u00e1cil de alterar a cor de fundo de um gr\u00e1fico no Matplotlib \u00e9 usar o argumento <strong>set_facecolor()<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Se voc\u00ea definir uma figura e um eixo no Matplotlib usando a seguinte sintaxe:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> ()\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ent\u00e3o voc\u00ea pode simplesmente usar a seguinte sintaxe para definir a cor de fundo do gr\u00e1fico:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>ax. <span style=\"color: #3366ff;\">set_facecolor<\/span> (' <span style=\"color: #008000;\">pink<\/span> ')\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Este tutorial fornece v\u00e1rios exemplos de uso pr\u00e1tico desta fun\u00e7\u00e3o.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 1: Defina a cor de fundo usando o nome da cor<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como definir a cor de fundo de um gr\u00e1fico Matplotlib usando o nome de uma cor:<\/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 plot figure and axis\n<\/span>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> ()\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 and specify background color to be pink\n<\/span>ax. <span style=\"color: #3366ff;\">scatter<\/span> (A, B)\nax. <span style=\"color: #3366ff;\">set_facecolor<\/span> (' <span style=\"color: #008000;\">pink<\/span> ')\n\n<span style=\"color: #008080;\">#display scatterplot<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11802 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/couleur-darriere-plan1.png\" alt=\"Cor de fundo no Matplotlib\" width=\"393\" height=\"262\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 2: Definir a cor de fundo usando c\u00f3digo de cores hexadecimal<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como definir a cor de fundo de um gr\u00e1fico Matplotlib usando um c\u00f3digo de cores hexadecimal:<\/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 plot figure and axis\n<\/span>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> ()\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 and specify background color to be pink\n<\/span>ax. <span style=\"color: #3366ff;\">scatter<\/span> (A, B)\nax. <span style=\"color: #3366ff;\">set_facecolor<\/span> (' <span style=\"color: #008000;\">#33FFA2<\/span> ')\n\n<span style=\"color: #008080;\">#display scatterplot<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11803 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/couleur-darriere-plan2.png\" alt=\"Cor de fundo do Matlplotlib usando c\u00f3digo de cores hexadecimal\" width=\"413\" height=\"276\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 3: Defina a cor de fundo para uma subtrama espec\u00edfica<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">\u00c0s vezes voc\u00ea ter\u00e1 v\u00e1rios gr\u00e1ficos do Matplotlib. Nesse caso, voc\u00ea pode usar o c\u00f3digo a seguir para especificar a cor de fundo de um \u00fanico gr\u00e1fico:<\/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 subplots\n<\/span>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> (2, 2)\nfig. <span style=\"color: #3366ff;\">tight_layout<\/span> ()\n\n<span style=\"color: #008080;\">#define background color to use for each subplot\n<\/span>ax[0,0]. <span style=\"color: #3366ff;\">set_facecolor<\/span> (' <span style=\"color: #008000;\">blue<\/span> ')\nax[0,1]. <span style=\"color: #3366ff;\">set_facecolor<\/span> (' <span style=\"color: #008000;\">pink<\/span> ')\nax[1,0]. <span style=\"color: #3366ff;\">set_facecolor<\/span> (' <span style=\"color: #008000;\">green<\/span> ')\nax[1,1]. <span style=\"color: #3366ff;\">set_facecolor<\/span> (' <span style=\"color: #008000;\">red<\/span> ')\n\n<span style=\"color: #008080;\">#display subplots<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11804 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/couleur-darriere-plan3.png\" alt=\"Subtramas Matplotlib com origens diferentes\" width=\"456\" height=\"307\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\"><strong>Relacionado:<\/strong><\/span> <a href=\"https:\/\/statorials.org\/pt\/espacamento-de-subtrama-matplotlib\/\" target=\"_blank\" rel=\"noopener noreferrer\">Como ajustar o espa\u00e7amento entre subtramas do Matplotlib<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A maneira mais f\u00e1cil de alterar a cor de fundo de um gr\u00e1fico no Matplotlib \u00e9 usar o argumento set_facecolor() . Se voc\u00ea definir uma figura e um eixo no Matplotlib usando a seguinte sintaxe: fig, ax = plt. subplots () Ent\u00e3o voc\u00ea pode simplesmente usar a seguinte sintaxe para definir a cor de fundo [&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-1186","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 alterar a cor de fundo no Matplotlib (com exemplos)<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como alterar a cor de fundo de uma figura no Matplotlib, 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\/cor-de-fundo-do-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como alterar a cor de fundo no Matplotlib (com exemplos)\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como alterar a cor de fundo de uma figura no Matplotlib, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T08:55:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/couleur-darriere-plan1.png\" \/>\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\/cor-de-fundo-do-matplotlib\/\",\"url\":\"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/\",\"name\":\"Como alterar a cor de fundo no Matplotlib (com exemplos)\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-27T08:55:04+00:00\",\"dateModified\":\"2023-07-27T08:55:04+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como alterar a cor de fundo de uma figura no Matplotlib, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como alterar a cor de fundo no matplotlib (com 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 alterar a cor de fundo no Matplotlib (com exemplos)","description":"Este tutorial explica como alterar a cor de fundo de uma figura no Matplotlib, 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\/cor-de-fundo-do-matplotlib\/","og_locale":"pt_PT","og_type":"article","og_title":"Como alterar a cor de fundo no Matplotlib (com exemplos)","og_description":"Este tutorial explica como alterar a cor de fundo de uma figura no Matplotlib, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/","og_site_name":"Statorials","article_published_time":"2023-07-27T08:55:04+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/couleur-darriere-plan1.png"}],"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\/cor-de-fundo-do-matplotlib\/","url":"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/","name":"Como alterar a cor de fundo no Matplotlib (com exemplos)","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-27T08:55:04+00:00","dateModified":"2023-07-27T08:55:04+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como alterar a cor de fundo de uma figura no Matplotlib, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/cor-de-fundo-do-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como alterar a cor de fundo no matplotlib (com 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\/1186","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=1186"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1186\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=1186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=1186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=1186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}