diff options
author | Jan Huwald <jh@sotun.de> | 2012-05-07 20:01:51 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2012-05-07 20:01:51 (GMT) |
commit | 420d2ef464d4a741028e132e662d5626806a41f5 (patch) | |
tree | 1aca6eb512e4ed0fb5f3c10c528cb998b6ffd695 /R |
Diffstat (limited to 'R')
-rwxr-xr-x | R/hist.R | 12 | ||||
-rw-r--r-- | R/plot.R | 33 | ||||
-rw-r--r-- | R/plot_all.R | 21 |
3 files changed, 66 insertions, 0 deletions
diff --git a/R/hist.R b/R/hist.R new file mode 100755 index 0000000..b04ae8e --- /dev/null +++ b/R/hist.R @@ -0,0 +1,12 @@ +files = commandArgs(trailingOnly=TRUE); +if (length(files) < 2) { + quit(); +} + +png(files[1]); +par(mfcol=(2, ceiling((length(files)-1)/2))); + +for (f in files[2:length(files)) { + x = read.table(f, sep="\t")[[2]]; + hist(x); +} diff --git a/R/plot.R b/R/plot.R new file mode 100644 index 0000000..b608148 --- /dev/null +++ b/R/plot.R @@ -0,0 +1,33 @@ +# parse cmd line args +args = commandArgs(trailingOnly=TRUE); +src = args[1]; +dst = args[2]; +yname = args[3]; +ids = as.vector(strsplit(args[4], ","))[[1]]; +#ids = as.vector(sapply(strsplit(args[3], ","), as.numeric)); + +# read data +data = read.table(src, colClasses="double") + +# setup output +format = substr(dst, nchar(dst)-3, nchar(dst)); +if (format == ".pdf" || format == "pdf~") { + pdf(file = dst) +} + +# plot data +nids = length(ids); +xrange = range(data[1]); +yrange = range(data[2:(1+nids)]); + + +colors = rainbow(nids, start=0, end=0.1); +linetype = c(1:nids); + +plot(xrange, yrange, type="n", xlab="time [s]", ylab=yname); +for (i in 1:nids) { + lines(as.vector(data[[1]]), as.vector(data[[1+i]]), lty=linetype[i], col=colors[i]); +} +if (nids > 1) { + legend(x="topleft", legend=ids, lty=linetype, col=colors); +} diff --git a/R/plot_all.R b/R/plot_all.R new file mode 100644 index 0000000..acad509 --- /dev/null +++ b/R/plot_all.R @@ -0,0 +1,21 @@ +# parse cmd line args +args = commandArgs(trailingOnly=TRUE); +src = args[1]; +dst = args[2]; + +# read data +data = read.table(src, colClasses="double") + +# setup output +format = substr(dst, nchar(dst)-3, nchar(dst)); +if (format == ".pdf" || format == "pdf~") { + pdf(file = dst) +} + +# plot data +require(gplots); +hist2d(data, nbins=200, col=c("white", heat.colors(12))); +#fac=0.05; +#rfac=1/fac; +#par(pty="s", pch=22, cex=fac, cex.axis=rfac, cex.lab=rfac, cex.main=rfac, cex.sub=rfac); +#plot.default(data, xlab="time [s]", ylab="neuron #"); |