-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
I'm adding a color aesthetic to a faceted histogram. In the reprex below, with no color aesthetic, the histogram only show data within that facet level. However, with color defined, a baseline is added which stretches the stretches to include the range of data across all facets. The ideal behavior would be something similar to geom_density
with trim = TRUE
.
library(tidyverse)
set.seed(9416)
data <- tibble(a = rchisq(1000, df = 3),
b = rchisq(1000, df = 1),
c = rchisq(1000, df = 10)) %>%
gather()
ggplot(data, aes(x = value)) +
geom_histogram() +
facet_wrap(~ key, ncol = 1)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(data, aes(x = value)) +
geom_histogram(color = "red") +
facet_wrap(~ key, ncol = 1)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(data, aes(x = value)) +
geom_density(color = "red", trim = TRUE) +
facet_wrap(~ key, ncol = 1)
Created on 2019-07-22 by the reprex package (v0.3.0)
Based on this response on StackOverflow, it seems like it would be fairly straightforward to add a trim
argument to StatBin
. Is this something you would consider/accept a PR for?
Thanks!