Reputation: 29968
This histogram is really ugly:
hist(rbinom(10000, 20000, 0.0001),freq=F,right=F)
I don't want spaces between my bars. I tried different breaks=
methods but they all produce similar results. Any ideas?
I also want each bin value (or mean values )to be printed under the center of it's bar.
Upvotes: 1
Views: 17364
Reputation: 68809
Here is a way to center the labels:
x <- rbinom(1000, 2000, 0.001)
tmp <- hist(x, breaks=0:(max(x)+1), xaxt="n", right=FALSE, freq=FALSE)
axis(1, at=tmp$mids, labels=0:max(x))
Upvotes: 6
Reputation: 51640
Also:
x <- rbinom(10000, 20000, 0.0001)
hist(x, br = seq(-0.01, max(x)+1, 1), freq=F, col="black")
(the col="black"
is not necessary, of course, I just find it more readeable in black!)
Upvotes: 0
Reputation: 18628
In such a case I usually use:
hist(rbinom(1000,2000,0.0001),breaks=function(x) length(unique(x)))
Upvotes: 2
Reputation: 66842
if the values are integer and simply you want to count up them, how about
barplot(table(rbinom(10000, 20000, 0.0001)))
Upvotes: 4