[R] ggplot stat_bin question

Glenn Schultz glennmschultz at me.com
Wed Jun 3 02:32:10 CEST 2015


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")



More information about the R-help mailing list