简体   繁体   中英

Trouble with notches ggplot2

I am attempting to create a notched boxplot in ggplot2, thus:

m <- ggplot(dat, aes(y = Slope, x = factor(BB),
fill=factor(BB)))


m + geom_boxplot(notch = TRUE) 

However the plot produced is just a normal boxplot without notches. Has anyone encountered this issue before? Is there a way around it? I'm not sure if i'm missing something really obvious here!

I cna't put my own data up but I am getting the same result with the example dataset from ggplot2:

p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(notch = TRUE, notchwidth = .3)

My session info is:

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] splines   grid      stats     graphics  grDevices utils     datasets  methods       base     

other attached packages:
 [1] mgcv_1.7-6       gam_1.06.2       caper_0.5        mvtnorm_0.9-9991 MASS_7.3-13          ape_3.0-1       
 [7] ggplot2_0.8.9    proto_0.3-9.2    reshape_0.8.4    plyr_1.7.1      

loaded via a namespace (and not attached):
[1] digest_0.5.1       gee_4.13-17        lattice_0.19-33    Matrix_0.999375-50     nlme_3.1-101      
[6] tools_2.13.1      

I suppose that your problem is because you are using an older version of ggplot2. Noting @joran's comment, I'd also recommend to update R first before updating packages.

Then, you can install/update ggplot2 and all its dependencies by:

install.packages("ggplot2", dependencies = TRUE)

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM