-
Notifications
You must be signed in to change notification settings - Fork 0
/
hist.R
28 lines (17 loc) · 856 Bytes
/
hist.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library(ggplot2)
args <- commandArgs(TRUE)
indat <- read.table(args[1])
outname = paste(args[1],"png",sep=".");
xaxislabeltext = args[2]
png(file=outname, width=1000, height=400);
# This one works:
# hist(as.numeric(indat[,1]), xlim=c(0, 1), breaks=50, xlab=xaxislabeltext, ylab="Occurrences", col="red", main="")
# ggplot(indat, aes(x=xaxislabeltext)) + geom_histogram(binwidth=0.01)
outname = paste(args[1],"gg.png",sep=".");
png(file=outname, width=1000, height=400);
# ggplot(indat, aes(x=xaxislabeltext)) + geom_density()
ggplot(as.numeric(indat[,1]), aes(x=xaxislabeltext)) +
geom_histogram(aes(y=..density..), # Histogram with density instead of count on y-axis
binwidth=.5,
colour="black", fill="white") +
geom_density(alpha=.2, fill="#FF6666") # Overlay with transparent density plot