Closed bencneely closed 3 years ago
If you want to color by number of observations it's probably easiest to pre-calculate that number before feeding the data into ggplot2. Alternatively, you could consider jittered points.
library(tidyverse)
library(ggridges)
diamonds %>%
group_by(cut) %>%
mutate(count = n()) %>%
ggplot(aes(x = price, y = cut, fill = count)) +
geom_density_ridges(scale = 4) +
scale_y_discrete(expand = c(0, 0)) + # will generally have to set the `expand` option
scale_x_continuous(expand = c(0, 0)) + # for both axes to remove unneeded padding
coord_cartesian(clip = "off") + # to avoid clipping of the very top of the top ridgeline
theme_ridges()
#> Picking joint bandwidth of 458
Created on 2020-10-26 by the reprex package (v0.3.0)
I'm going to close this issue because it's not clear what feature is being requested. Please ask such questions on stackoverflow first, and if discussion there suggests that there's a missing feature in ggridges, then feel free to make a request.
That did it! The fill= in the aes() is what I was missing. My apologies for not asking appropriately. I am pretty new to this. Thanks so much for the help!
You should think about it this way:
First, thank you for a great package that gets a lot of use in my shop. One thing I have been unable to figure out is how to indicate magnitude of observations. For example, the attached image shows relative size structure of a fish population over 10 years. I'd like to show how many individuals were used to create each ridge plot. In this example, we only have 12 fish encountered in 2013 but around 300 in 2020. I'd like a way to differentiate so we could identify large and small samples at a glance. I envision a product that looks like your example of temperature in Lincoln, but with the scale according to number of observations rather than mean value. I wish I was more savvy with R so I could initiate a pull request, but I just don't have the skillset. Thank you for your consideration!![MELR crappie](https://user-images.githubusercontent.com/43911822/97204547-352a0400-1784-11eb-990a-d3753f929bf1.png)