Symmetrical histograms
I want to make a series of symmetrical histograms to show the abundance of butterflies over time. Here's a site that shows the shape of the charts I'm trying to create: http://thebirdguide.com/pelagics/bar_chart.htm
For convenience, I will use the aperture kit.
library(ggplot2)
g <- ggplot(iris, aes(Sepal.Width)) + geom_histogram(binwidth=.5)
g + coord_fixed(ratio = .003)
Essentially, I would like to reflect this histogram below the x-axis. Another way to think about the problem is to create a horizontal violin diagram with individual cells. I have looked through the template package and ggplot2 documentation but didn't find a solution anywhere. I prefer to use ggplot2, but other solutions in basic R, lattices or other packages would be fine.
source to share
Without your exact details, I can offer a rough coding solution, but this is a start for you (if you add more details, I'll be happy to help you set up the plot). Here's the code:
library(ggplot2)
noSpp <- 3
nTime <- 10
d <- data.frame(
JulianDate = rep(1:nTime , times = noSpp),
sppAbundance = c(c(1:5, 5:1),
c(3:5, 5:1, 1:2),
c(5:1, 1:5)),
yDummy = 1,
sppName = rep(letters[1:noSpp], each = nTime))
ggplot(data = d, aes(x = JulianDate, y = yDummy, size = sppAbundance)) +
geom_line() + facet_grid( sppName ~ . ) + ylab("Species") +
xlab("Julian Date")
And here's the figure.
source to share