Change scale of histogram in R
45,842
A complete (but not reproducible/testable) solution based on the comments above, with some attempt to reproduce the ggplot style ...
opar <- options(scipen=100)
par(bg="gray") ## set plot background color
hist(df$FutureCost,
main="Multicare Distribution of charges",
xlab="Charge($)",
breaks="FD",
xlim=c(0,500000),col="black")
grid(col="white") ## plots on top of histogram; re-plot
## histogram if you like ...
par(opar) ## restore original settings
Author by
tubby
Updated on February 04, 2020Comments
-
tubby over 4 years
My histogram has only one bin in it. How can I convert it in a way such that it has more bins?
I would like to convert graph 2 in the attached image to something resembling graph 1, such that I see more bins.
EDIT :
Upon doing
hist(df$FutureCost,main="Multicare Distribution of charges", xlab="Charge($)",breaks="FD",xlim=c(0,500000))
, I was able to get a better graph. Thanks to the replies. How can I convert the numbers 1e+05, 2e+05 etc to numbers like 100000, 200000 etc.