I would like to represent my data (PCA) as two (even more) overlapping 2D density regions, colored by a specific factor. For each factor value, the most 'densely populated' area should be also darker than less populated regions.
I used stat_density_2d()
:
ggplot(mydf, aes(PC1, PC2,colour=as.factor(class))) +
stat_density_2d()
getting this plot: PCA with contours
Then, I tried different combination of stat_density_2d(aes())
arguments, such as fill=
, but unsuccessfully.