[R] ggplot stat_bin question

John Kane jrkrideau at inbox.com
Wed Jun 3 14:25:40 CEST 2015


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!



More information about the R-help mailing list