{"id":2890,"date":"2023-07-20T05:38:33","date_gmt":"2023-07-20T05:38:33","guid":{"rendered":"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/"},"modified":"2023-07-20T05:38:33","modified_gmt":"2023-07-20T05:38:33","slug":"pojemniki-histogramu-ggplot","status":"publish","type":"post","link":"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/","title":{"rendered":"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Mo\u017cesz u\u017cy\u0107 argumentu <strong>bins<\/strong> , aby okre\u015bli\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w <a href=\"https:\/\/ggplot2.tidyverse.org\/\" target=\"_blank\" rel=\"noopener\">ggplot2<\/a> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\nggplot(df, <span style=\"color: #3366ff;\">aes<\/span> (x=x)) +\n  geom_histogram(bins= <span style=\"color: #008000;\">10<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Poni\u017csze przyk\u0142ady pokazuj\u0105, jak zastosowa\u0107 ten argument w praktyce.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Przyk\u0142ad: ustaw liczb\u0119 przedzia\u0142\u00f3w dla histogramu w ggplot2<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Poni\u017cszy kod pokazuje, jak utworzy\u0107 zbi\u00f3r danych w R zawieraj\u0105cy 10 000 losowych warto\u015bci zgodnych z <a href=\"https:\/\/statorials.org\/pl\/dystrybucja-ryb\/\" target=\"_blank\" rel=\"noopener\">rozk\u0142adem Poissona<\/a> ze \u015bredni\u0105 warto\u015bci\u0105 2:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (0)\n\n<span style=\"color: #008080;\">#create data frame with 10,000 random values that follow Poisson distribution\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (values=rpois(n= <span style=\"color: #008000;\">10000<\/span> , lambda= <span style=\"color: #008000;\">2<\/span> ))\n\n<span style=\"color: #008080;\">#view first five rows of data frame\n<\/span>head(df)\n\n  values\n1 4\n2 1\n3 1\n4 2\n5 4\n6 1\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Mo\u017cemy u\u017cy\u0107 poni\u017cszego kodu, aby utworzy\u0107 histogram w ggplot2 w celu wizualizacji rozk\u0142adu warto\u015bci w ramce danych:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\nggplot(df, <span style=\"color: #3366ff;\">aes<\/span> (x=values)) +\n  geom_histogram(fill=' <span style=\"color: #ff0000;\">steelblue<\/span> ', col=' <span style=\"color: #ff0000;\">black<\/span> ')<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25258 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/binshist1.jpg\" alt=\"\" width=\"447\" height=\"448\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Domy\u015blnie ggplot2 automatycznie wybierze okre\u015blon\u0105 liczb\u0119 p\u00f3l do u\u017cycia na histogramie.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Mo\u017cemy jednak u\u017cy\u0107 nast\u0119puj\u0105cej sk\u0142adni, aby okre\u015bli\u0107, \u017ce histogram ma u\u017cywa\u0107 <strong>10<\/strong> przedzia\u0142\u00f3w:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\nggplot(df, <span style=\"color: #3366ff;\">aes<\/span> (x=values)) +\n  geom_histogram(fill=' <span style=\"color: #ff0000;\">steelblue<\/span> ', col=' <span style=\"color: #ff0000;\">black<\/span> ', bins= <span style=\"color: #008000;\">10<\/span> )<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25259 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/binshist2.jpg\" alt=\"\" width=\"453\" height=\"451\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Zauwa\u017c, \u017ce histogram ma teraz dok\u0142adnie <strong>10<\/strong> p\u00f3l.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Mo\u017cemy te\u017c u\u017cy\u0107 nast\u0119puj\u0105cej sk\u0142adni, aby okre\u015bli\u0107, \u017ce histogram ma u\u017cywa\u0107 <strong>5<\/strong> przedzia\u0142\u00f3w:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\nggplot(df, <span style=\"color: #3366ff;\">aes<\/span> (x=values)) +\n  geom_histogram(fill=' <span style=\"color: #ff0000;\">steelblue<\/span> ', col=' <span style=\"color: #ff0000;\">black<\/span> ', bins= <span style=\"color: #008000;\">5<\/span> )<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25260 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/binshist3.jpg\" alt=\"\" width=\"441\" height=\"444\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Zauwa\u017c, \u017ce histogram ma teraz dok\u0142adnie <strong>5<\/strong> p\u00f3l.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Przekonasz si\u0119, \u017ce <strong>im mniej pojemnik\u00f3w u\u017cyjesz, tym szerszy b\u0119dzie ka\u017cdy pojemnik.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Og\u00f3lnie rzecz bior\u0105c, je\u015bli u\u017cyjesz zbyt ma\u0142ej liczby grup, prawdziwy rozk\u0142ad warto\u015bci zostanie ukryty.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Je\u015bli jednak u\u017cyjesz zbyt wielu grup, ryzykujesz po prostu zobaczeniem szumu w danych.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Jednym ze sposob\u00f3w znalezienia optymalnej liczby pojemnik\u00f3w do u\u017cycia w histogramie jest skorzystanie z <strong>regu\u0142y Sturgesa<\/strong> . Wi\u0119cej informacji na temat tej zasady <a href=\"https:\/\/statorials.org\/pl\/sturges-zasada-1\/\" target=\"_blank\" rel=\"noopener\">znajdziesz tutaj<\/a> .<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Uwaga<\/strong> : Pe\u0142n\u0105 dokumentacj\u0119 funkcji <strong>geom_histogram<\/strong> mo\u017cna znale\u017a\u0107 <a href=\"https:\/\/ggplot2.tidyverse.org\/reference\/geom_histogram.html\" target=\"_blank\" rel=\"noopener\">tutaj<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Dodatkowe zasoby<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Poni\u017csze samouczki wyja\u015bniaj\u0105, jak tworzy\u0107 inne popularne wykresy w R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pl\/histogram-czestotliwosci-wzglednej-r\/\" target=\"_blank\" rel=\"noopener\">Jak utworzy\u0107 histogram cz\u0119stotliwo\u015bci wzgl\u0119dnej w R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pl\/wiele-wykresow-pude\u0142kowych-r\/\" target=\"_blank\" rel=\"noopener\">Jak wykre\u015bli\u0107 wiele wykres\u00f3w skrzynkowych na jednym wykresie w R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pl\/jak-wykreslic-wiele-linii-serii-danych-na-wykresie-w-r\/\" target=\"_blank\" rel=\"noopener\">Jak wykre\u015bli\u0107 wiele linii na wykresie w R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mo\u017cesz u\u017cy\u0107 argumentu bins , aby okre\u015bli\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w ggplot2 : library (ggplot2) ggplot(df, aes (x=x)) + geom_histogram(bins= 10 ) Poni\u017csze przyk\u0142ady pokazuj\u0105, jak zastosowa\u0107 ten argument w praktyce. Przyk\u0142ad: ustaw liczb\u0119 przedzia\u0142\u00f3w dla histogramu w ggplot2 Poni\u017cszy kod pokazuje, jak utworzy\u0107 zbi\u00f3r danych w R zawieraj\u0105cy 10 000 losowych [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2890","post","type-post","status-publish","format-standard","hentry","category-przewodnik"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2 - Statorials<\/title>\n<meta name=\"description\" content=\"W tym samouczku wyja\u015bniono, jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.\" \/>\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\/pl\/pojemniki-histogramu-ggplot\/\" \/>\n<meta property=\"og:locale\" content=\"pl_PL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2 - Statorials\" \/>\n<meta property=\"og:description\" content=\"W tym samouczku wyja\u015bniono, jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-20T05:38:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/binshist1.jpg\" \/>\n<meta name=\"author\" content=\"Benjamin Anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Napisane przez\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin Anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Szacowany czas czytania\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuty\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/\",\"url\":\"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/\",\"name\":\"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2 - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pl\/#website\"},\"datePublished\":\"2023-07-20T05:38:33+00:00\",\"dateModified\":\"2023-07-20T05:38:33+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pl\/#\/schema\/person\/6484727a4612df3e69f016c3129c6965\"},\"description\":\"W tym samouczku wyja\u015bniono, jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/#breadcrumb\"},\"inLanguage\":\"pl-PL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Dom\",\"item\":\"https:\/\/statorials.org\/pl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/pl\/#website\",\"url\":\"https:\/\/statorials.org\/pl\/\",\"name\":\"Statorials\",\"description\":\"Tw\u00f3j przewodnik po kompetencjach statystycznych!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/pl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pl-PL\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/pl\/#\/schema\/person\/6484727a4612df3e69f016c3129c6965\",\"name\":\"Benjamin Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pl-PL\",\"@id\":\"https:\/\/statorials.org\/pl\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/pl\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/pl\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin Anderson\"},\"description\":\"Cze\u015b\u0107, jestem Benjamin i jestem emerytowanym profesorem statystyki, kt\u00f3ry zosta\u0142 oddanym nauczycielem Statorials. Dzi\u0119ki bogatemu do\u015bwiadczeniu i wiedzy specjalistycznej w dziedzinie statystyki ch\u0119tnie dziel\u0119 si\u0119 swoj\u0105 wiedz\u0105, aby wzmocni\u0107 pozycj\u0119 uczni\u00f3w za po\u015brednictwem Statorials. Wiedzie\u0107 wi\u0119cej\",\"sameAs\":[\"https:\/\/statorials.org\/pl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2 - Statorials","description":"W tym samouczku wyja\u015bniono, jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.","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\/pl\/pojemniki-histogramu-ggplot\/","og_locale":"pl_PL","og_type":"article","og_title":"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2 - Statorials","og_description":"W tym samouczku wyja\u015bniono, jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.","og_url":"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/","og_site_name":"Statorials","article_published_time":"2023-07-20T05:38:33+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/binshist1.jpg"}],"author":"Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Napisane przez":"Benjamin Anderson","Szacowany czas czytania":"2 minuty"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/","url":"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/","name":"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2 - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/pl\/#website"},"datePublished":"2023-07-20T05:38:33+00:00","dateModified":"2023-07-20T05:38:33+00:00","author":{"@id":"https:\/\/statorials.org\/pl\/#\/schema\/person\/6484727a4612df3e69f016c3129c6965"},"description":"W tym samouczku wyja\u015bniono, jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w do u\u017cycia w histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.","breadcrumb":{"@id":"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/#breadcrumb"},"inLanguage":"pl-PL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pl\/pojemniki-histogramu-ggplot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Dom","item":"https:\/\/statorials.org\/pl\/"},{"@type":"ListItem","position":2,"name":"Jak ustawi\u0107 liczb\u0119 pojemnik\u00f3w dla histogramu w ggplot2"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/pl\/#website","url":"https:\/\/statorials.org\/pl\/","name":"Statorials","description":"Tw\u00f3j przewodnik po kompetencjach statystycznych!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/pl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pl-PL"},{"@type":"Person","@id":"https:\/\/statorials.org\/pl\/#\/schema\/person\/6484727a4612df3e69f016c3129c6965","name":"Benjamin Anderson","image":{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/statorials.org\/pl\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/pl\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/pl\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","caption":"Benjamin Anderson"},"description":"Cze\u015b\u0107, jestem Benjamin i jestem emerytowanym profesorem statystyki, kt\u00f3ry zosta\u0142 oddanym nauczycielem Statorials. Dzi\u0119ki bogatemu do\u015bwiadczeniu i wiedzy specjalistycznej w dziedzinie statystyki ch\u0119tnie dziel\u0119 si\u0119 swoj\u0105 wiedz\u0105, aby wzmocni\u0107 pozycj\u0119 uczni\u00f3w za po\u015brednictwem Statorials. Wiedzie\u0107 wi\u0119cej","sameAs":["https:\/\/statorials.org\/pl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/posts\/2890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/comments?post=2890"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/posts\/2890\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/media?parent=2890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/categories?post=2890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/tags?post=2890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}