I tend to use ecdf plots when viewing distributions, particularly if I have several distributions I'm trying to compare. Because these use lines rather than bars (histograms) or shapes (density plots) there is less of an issue with overlap.
library(data.table)
library(ggplot2)
set.seed(123)
dat_data <- data.table(meanval = rnorm(10),
sdval = runif(10, 0.5, 3),
rep = sample.int(1000, 10))
# meanval sdval rep
# 1: -0.56047565 2.7238483 964
# 2: -0.23017749 2.2320085 902
# 3: 1.55870831 2.1012670 690
# 4: 0.07050839 2.9856744 794
# 5: 0.12928774 2.1392645 25
# 6: 1.71506499 2.2713262 476
# 7: 0.46091621 1.8601651 754
# 8: -1.26506123 1.9853551 215
# 9: -0.68685285 1.2228993 316
# 10: -0.44566197 0.8677841 230
First, we generated some parameters for mean
, sd
, and rep
. Then, randomly sample rep
number of times from a normal distribution with a given mean
and sd
:
dat <- rbindlist(lapply(1:dim(dat_data)[1],
function(x) data.table(rowval = x,
dist = rnorm(dat_data[x, rep],
dat_data[x, meanval],
dat_data[x, sdval]))))
That gives a test dataset. You wouldn't need to do any of the above since you already have your data. Now we can plot the ecdf.
ggplot(dat, aes(x = dist, group = factor(rowval), color = factor(rowval))) +
stat_ecdf(size = 2)
You'll notice that row 5, which has the lowest rep number of 25, looks quite choppy. The degree of 'chop' can give you a clue as to the relative number, to some degree.
For reference, plotting the same data with geom_density
:
ggplot(dat, aes(x = dist, fill = factor(rowval))) +
geom_density(alpha = 0.3)