All, I am using gglpot to produce combination density and histogram plots, which are actually kinda cool, everything works well and the plots look nice. ?However after each plot run I receive the following message: stat_bin: binwidth defaulted to range/30. Use 'bin width = x' to adjust this. Below is the code I used to create the graph. ?I think I am pretty much following the examples in Hadley's ggplot2 book and really just need to eliminate the message as the graphs look fine. ?Any suggestions are appreciated. Best Regards, Glenn? ? Mdur.dist <- ggplot(OAS.Mdur, aes(x = value )) + ? ? geom_density(fill = "#56B4E9", colour = "#56B4E9", alpha = .6) + ? ? geom_histogram(aes(y =..density..), color = "lightgrey", fill = "#0072B2", bindwidth = .01) + ? ? theme_minimal() + ? ? #scale_x_continuous(breaks = seq(80,120, 5)) + ? ? labs(title = "Mod. Duration Distribution") + ? ? ylab("Density")+ ? ? xlab("Path Mod. Duration") + ? ? theme(panel.grid.major = element_line(size = .25, color = "grey")) + ? ? theme(axis.text = element_text(size = 15)) + ? ? theme(axis.title = element_text(size = 20)) +? ? ? theme(legend.position = "none")
Dear Glenn, Your code contains a typo: it has bindwidth instead of binwidth. Fixing that will no longer show the message. AFAIK, the message is always displayed when binwidth is not set. You can use suppressMessages() to hide them. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-06-03 2:32 GMT+02:00 Glenn Schultz <glennmschultz at me.com>:> All, > > I am using gglpot to produce combination density and histogram plots, > which are actually kinda cool, everything works well and the plots look > nice. However after each plot run I receive the following message: > > stat_bin: binwidth defaulted to range/30. Use 'bin width = x' to adjust > this. > > Below is the code I used to create the graph. I think I am pretty much > following the examples in Hadley's ggplot2 book and really just need to > eliminate the message as the graphs look fine. Any suggestions are > appreciated. > > Best Regards, > Glenn > > Mdur.dist <- ggplot(OAS.Mdur, aes(x = value )) + > geom_density(fill = "#56B4E9", colour = "#56B4E9", alpha = .6) + > geom_histogram(aes(y =..density..), color = "lightgrey", fill > "#0072B2", bindwidth = .01) + > theme_minimal() + > #scale_x_continuous(breaks = seq(80,120, 5)) + > labs(title = "Mod. Duration Distribution") + > ylab("Density")+ > xlab("Path Mod. Duration") + > theme(panel.grid.major = element_line(size = .25, color = "grey")) + > theme(axis.text = element_text(size = 15)) + > theme(axis.title = element_text(size = 20)) + > theme(legend.position = "none") > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]
I don't think there is any reason to get rid of that message unless you have a presentation problem, that is, you are including that output in a paper. All that is, AFAIK, is a notice that ggplot() is using the default binning rule. You can change the number of the bins if you need more granular or more agglomerated plots. It can be fu/informative to change binwidth and see what is happening. John Kane Kingston ON Canada> -----Original Message----- > From: glennmschultz at me.com > Sent: Wed, 03 Jun 2015 00:32:10 +0000 (GMT) > To: r-help at r-project.org > Subject: [R] ggplot stat_bin question > > All, > > I am using gglpot to produce combination density and histogram plots, > which are actually kinda cool, everything works well and the plots look > nice. ?However after each plot run I receive the following message: > > stat_bin: binwidth defaulted to range/30. Use 'bin width = x' to adjust > this. > > Below is the code I used to create the graph. ?I think I am pretty much > following the examples in Hadley's ggplot2 book and really just need to > eliminate the message as the graphs look fine. ?Any suggestions are > appreciated. > > Best Regards, > Glenn > > ? Mdur.dist <- ggplot(OAS.Mdur, aes(x = value )) + > ? ? geom_density(fill = "#56B4E9", colour = "#56B4E9", alpha = .6) + > ? ? geom_histogram(aes(y =..density..), color = "lightgrey", fill > "#0072B2", bindwidth = .01) + > ? ? theme_minimal() + > ? ? #scale_x_continuous(breaks = seq(80,120, 5)) + > ? ? labs(title = "Mod. Duration Distribution") + > ? ? ylab("Density")+ > ? ? xlab("Path Mod. Duration") + > ? ? theme(panel.grid.major = element_line(size = .25, color = "grey")) + > ? ? theme(axis.text = element_text(size = 15)) + > ? ? theme(axis.title = element_text(size = 20)) + > ? ? theme(legend.position = "none")____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!