Histogram density graph
-
- Posts: 4
- Joined: Tue Feb 11, 2025 5:56 pm
Histogram density graph
Recently when I make histograms with the density option, some of the density curves overlap. Is that a bug? It previously didn't happen in the same files.
- Attachments
-
- Jamovi histogram.png (19.19 KiB) Viewed 14165 times
Re: Histogram density graph
Are you saying that the exact same data, but with an older version of jamovi, yields non-overlapping curves?
-
- Posts: 4
- Joined: Tue Feb 11, 2025 5:56 pm
Re: Histogram density graph
I'm saying that at the end of last yaer it did not happen to me, and now all cases seem to have a significantly weird overlap. Does it has something to do with the size of the sample?
Re: Histogram density graph
you could attach a .omv file of those analyses here (you may need to zip it up first), and we'll see if there's something we might want to tweak here. it is quite unusual looking data, so we may or may not want to intervene here.
jonathon
jonathon
-
- Posts: 4
- Joined: Tue Feb 11, 2025 5:56 pm
Re: Histogram density graph
Please find attached an example of it (while setting the example, I have noticed that if I change the order of the variables, the "bug" on the densities changes a bit, but still overlaps in most cases).
- Attachments
-
- Histogram bug.omv
- (388.52 KiB) Downloaded 386 times
Re: Histogram density graph
It's strange that it previously didn't happen with the same file, as the library that we're using to make these plots (ggrides) hasn't changed in over a year. I looked into the issue and it indeed has to do with groups having 2 or fewer data points. However, I looked into the issue and it seems that there is an easy fix to the alignment issue:
I made a pull request to incorporate this fix into jamovi: www.github.com/jamovi/jmv/pull/426
Code: Select all
library(ggplot2)
library(ggridges)
set.seed(1337)
df <- data.frame(
dep = rnorm(40),
group = sample(
LETTERS[1:5],
40,
replace = TRUE,
prob = c(0.05, 0.25, 0.05, 0.6, 0.05)
)
)
# How jamovi currently generates the plot
plot_old <- ggplot(data=df, aes(x=dep, y=group, fill=group)) +
geom_density_ridges(stat="binline", bins=18, scale=0.9) +
geom_density_ridges(scale=0.9, alpha=0.4)
# How jamovi would generate the plot with the fix
plot_new <- ggplot(data=df, aes(x=dep, y=group, fill=group, height = after_stat(density))) +
geom_density_ridges(stat="binline", bins=18, scale=0.9) +
geom_density_ridges(scale=0.9, alpha=0.4, stat="density")
Re: Histogram density graph
i've pushed out the 2.6.25 which includes this fix.
cheers
jonathon
cheers
jonathon
-
- Posts: 4
- Joined: Tue Feb 11, 2025 5:56 pm
Re: Histogram density graph
I would like to thank the jamovi team for their prompt help and solution