{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/ggplot2/issues/1342","labels_url":"https://api.github.com/repos/hadley/ggplot2/issues/1342/labels{/name}","comments_url":"https://api.github.com/repos/hadley/ggplot2/issues/1342/comments","events_url":"https://api.github.com/repos/hadley/ggplot2/issues/1342/events","html_url":"https://github.com/hadley/ggplot2/issues/1342","id":106719345,"number":1342,"title":"default position for geom_histogram()","user":{"login":"romunov","id":544571,"avatar_url":"https://avatars.githubusercontent.com/u/544571?v=3","gravatar_id":"","url":"https://api.github.com/users/romunov","html_url":"https://github.com/romunov","followers_url":"https://api.github.com/users/romunov/followers","following_url":"https://api.github.com/users/romunov/following{/other_user}","gists_url":"https://api.github.com/users/romunov/gists{/gist_id}","starred_url":"https://api.github.com/users/romunov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romunov/subscriptions","organizations_url":"https://api.github.com/users/romunov/orgs","repos_url":"https://api.github.com/users/romunov/repos","events_url":"https://api.github.com/users/romunov/events{/privacy}","received_events_url":"https://api.github.com/users/romunov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-16T07:55:49Z","updated_at":"2015-09-16T08:03:08Z","closed_at":null,"body":"The default behavior of `geom_histogram(position = \"stack\")` may be a bit unexpected (alternatively, I would love to hear the reasoning behind the choice). I would expect, when plotting a histogram of `n` levels, to have `n` \"self contained\" histograms, overlapping for better or worse. On the other hand, doing `geom_density` plots the data \"as expected\" which is conceptually very similar to `geom_histogram`. My suggestion would be to consider changing the default position in `geom_histogram` to `position = \"identity\"`.\r\n\r\n```{r}\r\nxy <- data.frame(pop = sample(letters[1:2], 100, replace = TRUE), value = c(rnorm(50, mean = 5), rnorm(50, mean = 10)))\r\n\r\nlibrary(ggplot2)\r\n\r\n# overlapping histograms\r\nggplot(xy, aes(x = value, fill = pop)) +\r\n  theme_bw() +\r\n  geom_histogram(color = \"black\", position = \"identity\", alpha = 0.75) +\r\n  scale_fill_brewer(palette = \"Set1\")\r\n\r\n# stacked histogram, not very histogram-y anymore\r\nggplot(xy, aes(x = value, fill = pop)) +\r\n  theme_bw() +\r\n  geom_histogram(color = \"black\", alpha = 0.75) +\r\n  scale_fill_brewer(palette = \"Set1\")\r\n\r\n# density graphs do overlap\r\nggplot(xy, aes(x = value, fill = pop)) +\r\n  theme_bw() +\r\n  geom_density(alpha = 0.75) +\r\n  scale_fill_brewer(palette = \"Set1\")\r\n```"},"comment":{"url":"https://api.github.com/repos/hadley/ggplot2/issues/comments/140661074","html_url":"https://github.com/hadley/ggplot2/issues/1342#issuecomment-140661074","issue_url":"https://api.github.com/repos/hadley/ggplot2/issues/1342","id":140661074,"user":{"login":"zx8754","id":5212915,"avatar_url":"https://avatars.githubusercontent.com/u/5212915?v=3","gravatar_id":"","url":"https://api.github.com/users/zx8754","html_url":"https://github.com/zx8754","followers_url":"https://api.github.com/users/zx8754/followers","following_url":"https://api.github.com/users/zx8754/following{/other_user}","gists_url":"https://api.github.com/users/zx8754/gists{/gist_id}","starred_url":"https://api.github.com/users/zx8754/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zx8754/subscriptions","organizations_url":"https://api.github.com/users/zx8754/orgs","repos_url":"https://api.github.com/users/zx8754/repos","events_url":"https://api.github.com/users/zx8754/events{/privacy}","received_events_url":"https://api.github.com/users/zx8754/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T08:03:08Z","updated_at":"2015-09-16T08:03:08Z","body":":+1: "}}