{"id":2005,"date":"2023-07-24T02:59:17","date_gmt":"2023-07-24T02:59:17","guid":{"rendered":"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/"},"modified":"2023-07-24T02:59:17","modified_gmt":"2023-07-24T02:59:17","slug":"procent-histogramu-ggplot","status":"publish","type":"post","link":"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/","title":{"rendered":"Jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Mo\u017cesz u\u017cy\u0107 nast\u0119puj\u0105cej podstawowej sk\u0142adni, aby wy\u015bwietli\u0107 warto\u015bci procentowe na osi Y histogramu w ggplot2:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #993300;\">library<\/span> (ggplot2)\n<span style=\"color: #993300;\">library<\/span> (scales)\n\n<span style=\"color: #008080;\">#create histogram with percentages\n<\/span>ggplot(data, <span style=\"color: #3366ff;\">aes<\/span> (x = <span style=\"color: #3366ff;\">factor<\/span> (team))) +  \n  geom_bar( <span style=\"color: #3366ff;\">aes<\/span> (y = (..count..)\/ <span style=\"color: #3366ff;\">sum<\/span> (..count..))) +\n  scale_y_continuous(labels=percent)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Poni\u017csze przyk\u0142ady pokazuj\u0105, jak u\u017cywa\u0107 tej sk\u0142adni w praktyce.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Przyk\u0142ad 1: Podstawowy histogram z warto\u015bciami procentowymi<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Poni\u017cszy kod pokazuje, jak utworzy\u0107 histogram dla zmiennych jako\u015bciowych z warto\u015bciami procentowymi wy\u015bwietlanymi na osi Y:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #993300;\">library<\/span> (ggplot2)\n<span style=\"color: #993300;\">library<\/span> (scales)\n\n<span style=\"color: #008080;\">#define data frame\n<\/span>data &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (team = c('A', 'A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'C') ,\n                   points = c(77, 79, 93, 85, 89, 99, 90, 80, 68, 91, 92))\n\n<span style=\"color: #008080;\">#create histogram with percentages\n<\/span>ggplot(data, <span style=\"color: #3366ff;\">aes<\/span> (x = <span style=\"color: #3366ff;\">factor<\/span> (team))) +  \n  geom_bar( <span style=\"color: #3366ff;\">aes<\/span> (y = (..count..)\/ <span style=\"color: #3366ff;\">sum<\/span> (..count..))) +\n  scale_y_continuous(labels=percent)<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-18853 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pour-cent5.png\" alt=\"\" width=\"469\" height=\"524\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Przyk\u0142ad 2: histogram z warto\u015bciami procentowymi (usu\u0144 miejsca dziesi\u0119tne)<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Mo\u017cesz tak\u017ce u\u017cy\u0107 argumentu <strong>precyzji<\/strong> , aby wy\u015bwietli\u0107 tylko liczby ca\u0142kowite jako warto\u015bci procentowe na osi Y:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #993300;\">library<\/span> (ggplot2)\n<span style=\"color: #993300;\">library<\/span> (scales)\n\n<span style=\"color: #008080;\">#define data frame\n<\/span>data &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (team = c('A', 'A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'C') ,\n                   points = c(77, 79, 93, 85, 89, 99, 90, 80, 68, 91, 92))\n\n<span style=\"color: #008080;\">#create histogram with percentages\n<\/span>ggplot(data, <span style=\"color: #3366ff;\">aes<\/span> (x = <span style=\"color: #3366ff;\">factor<\/span> (team))) +  \n  geom_bar( <span style=\"color: #3366ff;\">aes<\/span> (y = (..count..)\/ <span style=\"color: #3366ff;\">sum<\/span> (..count..))) +\n  scale_y_continuous(labels = scales <span style=\"color: #a55cff;\">::<\/span> percent_format(accuracy = <span style=\"color: #008000;\">1L<\/span> ))<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-18852\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pourcentage4.png\" alt=\"Histogram ggplot2 z warto\u015bciami procentowymi\" width=\"473\" height=\"534\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Przyk\u0142ad 3: Niestandardowy histogram z warto\u015bciami procentowymi<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Poni\u017cszy kod pokazuje, jak utworzy\u0107 histogram z warto\u015bciami procentowymi wy\u015bwietlanymi na osi Y oraz niestandardowym tytu\u0142em, etykietami osi i kolorami:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #993300;\">library<\/span> (ggplot2)\n<span style=\"color: #993300;\">library<\/span> (scales)\n\n<span style=\"color: #008080;\">#define data frame\n<\/span>data &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (team = c('A', 'A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'C') ,\n                   points = c(77, 79, 93, 85, 89, 99, 90, 80, 68, 91, 92))\n\n<span style=\"color: #008080;\">#create histogram with percentages and custom aesthetics\n<\/span>ggplot(data, <span style=\"color: #3366ff;\">aes<\/span> (x = <span style=\"color: #3366ff;\">factor<\/span> (team))) +  \n  geom_bar( <span style=\"color: #3366ff;\">aes<\/span> (y = (..count..)\/ <span style=\"color: #3366ff;\">sum<\/span> (..count..)), fill = ' <span style=\"color: #ff0000;\">lightblue<\/span> ') +\n  scale_y_continuous(labels=percent) +\n  labs(title = ' <span style=\"color: #ff0000;\">Breakdown by Team<\/span> ', x = ' <span style=\"color: #ff0000;\">Team<\/span> ', y = ' <span style=\"color: #ff0000;\">Percent of Total<\/span> ') +\n  theme_minimal()\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-18854 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pour-cent6.png\" alt=\"\" width=\"462\" height=\"503\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\"><strong>Powi\u0105zane:<\/strong><\/span> <a href=\"https:\/\/statorials.org\/pl\/najlepsze-motywy-ggplot2\/\" target=\"_blank\" rel=\"noopener\">Kompletny przewodnik po najlepszych motywach ggplot2<\/a><\/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 wykonywa\u0107 inne typowe operacje na histogramach w R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pl\/r-rozmiar-histogramu\/\" target=\"_blank\" rel=\"noopener\">Jak zmieni\u0107 liczb\u0119 pojemnik\u00f3w na histogramie w R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pl\/wiele-histogramow-r\/\" target=\"_blank\" rel=\"noopener\">Jak wykre\u015bli\u0107 wiele histogram\u00f3w w R<\/a><br \/> <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><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mo\u017cesz u\u017cy\u0107 nast\u0119puj\u0105cej podstawowej sk\u0142adni, aby wy\u015bwietli\u0107 warto\u015bci procentowe na osi Y histogramu w ggplot2: library (ggplot2) library (scales) #create histogram with percentages ggplot(data, aes (x = factor (team))) + geom_bar( aes (y = (..count..)\/ sum (..count..))) + scale_y_continuous(labels=percent) Poni\u017csze przyk\u0142ady pokazuj\u0105, jak u\u017cywa\u0107 tej sk\u0142adni w praktyce. Przyk\u0142ad 1: Podstawowy histogram z warto\u015bciami procentowymi [&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-2005","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 wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2 - Statologia<\/title>\n<meta name=\"description\" content=\"W tym samouczku wyja\u015bniono, jak wy\u015bwietli\u0107 warto\u015bci procentowe na 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\/procent-histogramu-ggplot\/\" \/>\n<meta property=\"og:locale\" content=\"pl_PL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2 - Statologia\" \/>\n<meta property=\"og:description\" content=\"W tym samouczku wyja\u015bniono, jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T02:59:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pour-cent5.png\" \/>\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\/procent-histogramu-ggplot\/\",\"url\":\"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/\",\"name\":\"Jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2 - Statologia\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pl\/#website\"},\"datePublished\":\"2023-07-24T02:59:17+00:00\",\"dateModified\":\"2023-07-24T02:59:17+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pl\/#\/schema\/person\/6484727a4612df3e69f016c3129c6965\"},\"description\":\"W tym samouczku wyja\u015bniono, jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/#breadcrumb\"},\"inLanguage\":\"pl-PL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Dom\",\"item\":\"https:\/\/statorials.org\/pl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie 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 wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2 - Statologia","description":"W tym samouczku wyja\u015bniono, jak wy\u015bwietli\u0107 warto\u015bci procentowe na 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\/procent-histogramu-ggplot\/","og_locale":"pl_PL","og_type":"article","og_title":"Jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2 - Statologia","og_description":"W tym samouczku wyja\u015bniono, jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.","og_url":"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/","og_site_name":"Statorials","article_published_time":"2023-07-24T02:59:17+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pour-cent5.png"}],"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\/procent-histogramu-ggplot\/","url":"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/","name":"Jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2 - Statologia","isPartOf":{"@id":"https:\/\/statorials.org\/pl\/#website"},"datePublished":"2023-07-24T02:59:17+00:00","dateModified":"2023-07-24T02:59:17+00:00","author":{"@id":"https:\/\/statorials.org\/pl\/#\/schema\/person\/6484727a4612df3e69f016c3129c6965"},"description":"W tym samouczku wyja\u015bniono, jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie w ggplot2, podaj\u0105c kilka przyk\u0142ad\u00f3w.","breadcrumb":{"@id":"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/#breadcrumb"},"inLanguage":"pl-PL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pl\/procent-histogramu-ggplot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Dom","item":"https:\/\/statorials.org\/pl\/"},{"@type":"ListItem","position":2,"name":"Jak wy\u015bwietli\u0107 warto\u015bci procentowe na histogramie 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\/2005","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=2005"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/posts\/2005\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/media?parent=2005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/categories?post=2005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pl\/wp-json\/wp\/v2\/tags?post=2005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}