I like to have a "x vs. y"- plot in which the symbol colors represent a additional (or another :-) dimension z.
I’m sure that there are several ways to do that, however here is the way I understand.
Assume that x, y and z have the same length n :
n <- length(y)
At first I generate a vector from z (z will give the color) in the interval [0,1]
zp <- z - min(z) ## zp starts from 0 zpp <- zp/max(zp) ## zpp ends at 1
If I now multiply zpp by n I get a nice index vector which can be used together with the result produced by colorRampPalette():
cf <- colorRampPalette(c("blue","yellow","red"))
cf is a function. It’s argument is the length of the color vector which should be returned. Now put everything together:
Here is a complete example:
This is how it looks like:
Today I searched an old post. I used the tumblr search without success …
So I’ve started a new blog with some couchdb, git, node.js stuff I wrote last months. This kind of posts I will dump there.
Leave a comment on
or do it here. The blog is hosted on
It’s a couchapp. Comments?
One of my favorite R packages that I use all the time is the RColorBrewer package. The package has been around for a while now and is written/maintained by Erich Neuwirth. The guts of the package are based on Cynthia Brewer’s very cool work on the use of color in cartography (check out the colorbrewer web site).
As a side note, I think the ability to manipulate colors in plots/graphs/maps is one of R’s many great strengths. My personal experience is that getting the right color scheme can make a difference in how data are perceived in a plot.
generates regExp from nobrainer * expressions
> glob2rx("foo*.bar.*baz")  "^foo.*\\.bar\\..*baz$"
checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed USE_LOCAL = "" Using local libjson code. Copying files /tmp/Rtmp2n5YCn/R.INSTALL38c6756b/RJSONIO configure: creating ./config.status config.status: creating src/Makevars config.status: creating cleanup ** libs gcc -std=gnu99 -I/usr/lib/R/include -I. .... make: g++: Kommando nicht gefunden make: *** [JSONChildren.o] Fehler 127 ERROR: compilation failed for package ‘RJSONIO’
# ln -s g++-4.4 g++ # l g++ lrwxrwxrwx 1 root root 7 11. Okt 13:09 g++ -> g++-4.4*