r - histogram breaks with not continuous break points -
how set x-axis in histogram plot predefined break points instead of continuous break points.
breaks=c(0,5,10,100,200,1000) the break points chosen based on frequency in bin ranges. how achieve instead of breaks=c(0,5,10,15,20) continuous break points ?
edit: have calculated frequencies separately , plotted using geom_bar 
expecting similar output hist plot.
perhaps i'm not understanding problem. can't already?
x <- rnorm(1000, mean= 10, sd= 5) range(x) # need have whole range of x in histogram hist(x, breaks= c(range(x)[1], 0, 5, 7, 12, 20, range(x)[2])) library(ggplot2) brks=c(range(x)[1], 0, 5, 7, 12, 20, range(x)[2]) ggplot(data.frame(x), aes(x=x)) + geom_histogram(breaks= brks) + scale_x_continuous(breaks= brks) you add theme(... element_text()) options whatever formatting want
Comments
Post a Comment