Examples
I use the one-sided formula method for the below examples. But the atomic method (e.g., plt(Nile, type = "histogram")) works just the same.
pkgload::load_all("~/Documents/Projects/tinyplot") #> ℹ Loading tinyplot
Standard histogram
plt(~Petal.Length, iris, type = "hist") # "hist" is alias for "histogram"
Question: I haven't switched off the surrounding plot frame (box) by default. Should we do this to make it more consistent with base hist()?
plt(~Petal.Length, iris, type = "hist", frame = FALSE)
Grouped histograms
plt(~Petal.Length | Species, iris, type = "hist")
Question: By default, the fill of grouped histograms is solid. Should we rather enable automatic alpha fill transparency for these (see next examples)?
Aside: We can adjust the number of breaks by passing a breaks argument.
plt(~Petal.Length | Species, iris, type = "hist", fill = 0.5, breaks = 30)
Grouped and faceted histograms
We could also facet by itself (i.e., no colour grouping), although I don't show that here.
plt(~Petal.Length | Species, iris, type = "hist", fill = 0.5, breaks = 30, facet = "by")
Again, we haven't turned off the frame by default but we might want to...
plt(~Petal.Length | Species, iris, type = "hist", fill = 0.5, breaks = 30, facet = "by", frame = FALSE)
More elaborate example where we use different (colour) groups and facets.
iris2 = iris |> transform(long_sepal = Sepal.Length > mean(Sepal.Length)) plt(~Petal.Length | Species, iris2, type = "hist", fill = 0.5, breaks = 30, facet = ~long_sepal)
Created on 2024-07-11 with reprex v2.1.0