I have a histogram of a variable like
aa=-(a$mmag)/2.5
hist(10^(aa),breaks=40,xlab=expression(paste(mu)),ylab=NA)
How to diffuse the vertical lines in between ?
I have a histogram of a variable like
aa=-(a$mmag)/2.5
hist(10^(aa),breaks=40,xlab=expression(paste(mu)),ylab=NA)
How to diffuse the vertical lines in between ?
This is the only solution I could think of:
hist(rnorm(1000), col = "grey", border = "grey")
Basically we set line colour (border
) and filled colour (col
) to be the same. Don't try setting "white"; you see nothing from that.
Here's a function that should accomplish it... feel free to edit at will!
empty_hist <- function(x,...) {
histo <- hist(x,plot=F)
plot(NA,xlim=c(min(histo$breaks),max(histo$breaks)),ylim=c(0,max(histo$counts)),xlab="",ylab="count",...=...)
segments(x0=histo$breaks[1:(length(histo$breaks)-1)],x1=histo$breaks[2:length(histo$breaks)],y0=histo$counts,y1=histo$counts)
segments(x0=histo$breaks[2:(length(histo$breaks)-1)],x1=histo$breaks[2:(length(histo$breaks)-1)],y0=histo$counts[1:(length(histo$counts)-1)],y1=histo$counts[2:(length(histo$counts))])
segments(x0=histo$breaks[c(1,length(histo$breaks))],x1=histo$breaks[c(1,length(histo$breaks))],y0=c(0,0),y1=histo$counts[c(1,length(histo$counts))])
abline(h=0)
}
x <- rnorm(100)
empty_hist(x, main="here's a title")