Total members 11657 |It is currently Tue Aug 22, 2017 6:20 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





To plot a ggplot2 Boxplot you can take a look at the following snippet.
Code:
require(foreign)
require(
MASS)
require(
bootES)
library(ggplot2)
library(plyr) # might be not needed here anyway it is a must-have package I think in R 
library(reshape2) # to "melt" your dataset
library (scales) # it has a "rescale" function which is needed in heatmaps 
library(RColorBrewer) # for convenience of heatmap colors, it reflects your mood sometimes
require(beanplot)
library(plyr) # For the desc() function
library(ggplot2)
library(crop)
library(directlabels)
library(scales)
library(grid)
library(moments)

### Load your data here
## I loaded here data named"NewCalculation".


  p<- ggplot(NewCalculation, aes(factor(trainingSize), recall))+ geom_boxplot(fill="#ffff99")+ylim(0,1)+theme_bw()+
      labs(color = "Type",title =  ", Title here,")+ geom_hline(yintercept = yvals,color="RED",linetype="dashed")+
      ylab("Ylabel text")+xlab("Xlabel text")+ theme(legend.position = "bottom",text = element_text(size=14))
    
    p

Attachment:
ggplot2_boxplot.jpg
ggplot2_boxplot.jpg [ 39.75 KiB | Viewed 947 times ]

In this example, I actually print multiple boxplots from the data same data-frame. I used the x-axis by passing the "factor(trainingSize)" to aes function. Filled the boxplots with yellow color using "fill=...". The other parameters as just the traditional ones for any ggplot function.




Author:
Mastermind
User avatar Posts: 2707
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : ggplot2 for many boxplots in one figure example
 Good looking HeatMap example in R using ggplot2     -  



Topic Tags

R Analysis







Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team