Re: [R] Graph many points without hiding some

From: Claudia Beleites <cbeleites_at_units.it>
Date: Thu, 31 Mar 2011 10:59:39 +0200

> AFAIK, base graphics doesn't have alpha transparency available,
They do:
plot(rnorm(x,mean=19),rnorm(x),xlim=c(16,24), cex = 0.2, col = "#00000040")

Also, have a look at hexbin (with very small bins). Here's a ggplot2 version that gives different colors to the different groups of data: https://github.com/hadley/ggplot2/wiki/Case-Study%3A-Raman-Spectroscopic-Grading-of-Gliomas

If I have large differences in size of the groups, I sometimes combine the hexbin output for the large groups with points for the small groups (see the attachment if the file makes . IN ggplot2, you can just add them by geom_point () after the
geom_hex.

df <- data.frame (x = rnorm (10000), y = rnorm (10000),   grp = factor (sample (3, 10000, prob = c(1, 1, 1000), replace = TRUE)))

ggplot (df [FALSE,], aes (x = x, y = y, col = grp)) +

	stat_binhex (data = subset (df, grp == 3), col = NA) +
	geom_point (data = subset (df, ! grp == 3)) +
	scale_fill_gradient (low = "white", high = "black")

Claudia



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Thu 31 Mar 2011 - 10:20:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 Mar 2011 - 11:20:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive