{"id":2107,"date":"2023-07-23T16:04:54","date_gmt":"2023-07-23T16:04:54","guid":{"rendered":"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/"},"modified":"2023-07-23T16:04:54","modified_gmt":"2023-07-23T16:04:54","slug":"tamanho-do-compartimento-matplotlib","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/","title":{"rendered":"Como ajustar o tamanho do compartimento em histogramas matplotlib"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Voc\u00ea pode usar qualquer um dos seguintes m\u00e9todos para ajustar o tamanho do compartimento dos histogramas no Matplotlib:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 1: Especifique o n\u00famero de caixas<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>plt. <span style=\"color: #3366ff;\">hist<\/span> (data, bins= <span style=\"color: #008000;\">6<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 2: especifique os limites do intervalo<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>plt. <span style=\"color: #3366ff;\">hist<\/span> (data, bins=[0, 4, 8, 12, 16, 20])\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 3: Especifique a largura da caixa<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>w=2\nplt. <span style=\"color: #3366ff;\">hist<\/span> (data, bins=np. <span style=\"color: #3366ff;\">arange<\/span> (min(data), max(data) + w, w))<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como usar cada um desses m\u00e9todos na pr\u00e1tica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 1: Especifique o n\u00famero de compartimentos<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como especificar o n\u00famero de grupos a serem usados em um histograma:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><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 data\n<\/span>data = [1, 2, 2, 4, 5, 5, 6, 8, 9, 12, 14, 15, 15, 15, 16, 17, 19]\n\n<span style=\"color: #008080;\">#create histogram with specific number of bins\n<\/span>plt. <span style=\"color: #3366ff;\">hist<\/span> (data, edgecolor=' <span style=\"color: #ff0000;\">black<\/span> ', bins= <span style=\"color: #008000;\">6<\/span> ) \n<\/strong><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-19598\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/bac1.png\" alt=\"histograma matplotlib com n\u00famero espec\u00edfico de caixas\" width=\"530\" height=\"351\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Lembre-se de que quanto mais categorias voc\u00ea especificar, mais restritas ser\u00e3o as categorias.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 2:<\/strong><\/span> <span style=\"color: #000000;\"><strong>Especifique os limites do grupo<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como especificar os limites reais dos grupos em um histograma:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><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 data\n<\/span>data = [1, 2, 2, 4, 5, 5, 6, 8, 9, 12, 14, 15, 15, 15, 16, 17, 19]\n\n<span style=\"color: #008080;\">#create histogram with specific bin boundaries\n<\/span>plt. <span style=\"color: #3366ff;\">hist<\/span> (data, edgecolor=' <span style=\"color: #ff0000;\">black<\/span> ', bins=[0, 4, 8, 12, 16, 20])<\/span>\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-19599 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/poubelle2.png\" alt=\"\" width=\"533\" height=\"355\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Neste exemplo, especificamos que cada grupo deve ter a mesma largura, mas voc\u00ea pode especificar limites para que cada grupo tenha um tamanho diferente.<\/span><\/p>\n<h3> <strong>Exemplo 3: Especifique a largura da bandeja<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como especificar a largura do compartimento em um histograma:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#define data\n<\/span>data = [1, 2, 2, 4, 5, 5, 6, 8, 9, 12, 14, 15, 15, 15, 16, 17, 19]\n\n<span style=\"color: #008080;\">#specify bin width to use\n<\/span>w= <span style=\"color: #008000;\">2\n<\/span>\n<span style=\"color: #008080;\">#create histogram with specified bin width\n<\/span><\/span><span style=\"color: #000000;\">plt. <span style=\"color: #3366ff;\">hist<\/span> (data, edgecolor=' <span style=\"color: #ff0000;\">black<\/span> ', bins=np. <span style=\"color: #3366ff;\">arange<\/span> (min(data), max(data) + w, w))<\/span>\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-19600 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/poubelle3.png\" alt=\"\" width=\"527\" height=\"346\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Lembre-se de que quanto menor for a largura da caixa especificada, mais estreitas ser\u00e3o as caixas.<\/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 executar outras fun\u00e7\u00f5es comuns no Matplotlib:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/matplotlib-aumenta-o-tamanho-do-rastreamento\/\" target=\"_blank\" rel=\"noopener\">Como aumentar o tamanho do gr\u00e1fico no Matplotlib<\/a><br \/><a href=\"https:\/\/statorials.org\/pt\/grafico-de-densidade-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Como criar um gr\u00e1fico de densidade no Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/serie-temporal-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Como tra\u00e7ar uma s\u00e9rie temporal no Matplotlib<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar qualquer um dos seguintes m\u00e9todos para ajustar o tamanho do compartimento dos histogramas no Matplotlib: M\u00e9todo 1: Especifique o n\u00famero de caixas plt. hist (data, bins= 6 ) M\u00e9todo 2: especifique os limites do intervalo plt. hist (data, bins=[0, 4, 8, 12, 16, 20]) M\u00e9todo 3: Especifique a largura da caixa w=2 [&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-2107","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 ajustar o tamanho do compartimento em histogramas Matplotlib - Statorials<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como ajustar o tamanho do compartimento em histogramas 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\/tamanho-do-compartimento-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como ajustar o tamanho do compartimento em histogramas Matplotlib - Statorials\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como ajustar o tamanho do compartimento em histogramas Matplotlib, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T16:04:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/bac1.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\/tamanho-do-compartimento-matplotlib\/\",\"url\":\"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/\",\"name\":\"Como ajustar o tamanho do compartimento em histogramas Matplotlib - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-23T16:04:54+00:00\",\"dateModified\":\"2023-07-23T16:04:54+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como ajustar o tamanho do compartimento em histogramas Matplotlib, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como ajustar o tamanho do compartimento em histogramas matplotlib\"}]},{\"@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 ajustar o tamanho do compartimento em histogramas Matplotlib - Statorials","description":"Este tutorial explica como ajustar o tamanho do compartimento em histogramas 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\/tamanho-do-compartimento-matplotlib\/","og_locale":"pt_PT","og_type":"article","og_title":"Como ajustar o tamanho do compartimento em histogramas Matplotlib - Statorials","og_description":"Este tutorial explica como ajustar o tamanho do compartimento em histogramas Matplotlib, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/","og_site_name":"Statorials","article_published_time":"2023-07-23T16:04:54+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/bac1.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\/tamanho-do-compartimento-matplotlib\/","url":"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/","name":"Como ajustar o tamanho do compartimento em histogramas Matplotlib - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-23T16:04:54+00:00","dateModified":"2023-07-23T16:04:54+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como ajustar o tamanho do compartimento em histogramas Matplotlib, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/tamanho-do-compartimento-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como ajustar o tamanho do compartimento em histogramas matplotlib"}]},{"@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\/2107","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=2107"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2107\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=2107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=2107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=2107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}