If you want the size to depend on the data, then size needs to be inside aes(...). For instance: stat_bin(aes(label = sprintf("%.01f", (..count../288)*100), size=ifelse(..count..>0, 2.5, 0)) ,color="red", vjust=-0.5, angle=0, geom="text")
A better approach would be not to plot the unnecessary things at all. This should do it: stat_bin(aes(label = ifelse(..count..>0, sprintf("%.01f", (..count../288)*100), "")), size=2.5,color="red", vjust=-0.5, angle=0, geom="text") Best, Nello -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gundala Viswanath Sent: Dienstag, 25. Juni 2013 11:09 To: r-help@r-project.org; r-h...@stat.math.ethz.ch Subject: [R] How to include ifelse condition to adjust QPLOT font size I have a data which I plot using this code. Attached is the plot _BEGIN_ library(ggplot2) dat.m <- read.delim("http://dpaste.com/1269939/plain/",sep="") colnames(dat.m) <- c("ensg","mirna_hgc","variable","value") dat.m.y <- subset(dat.m,dat.m$variable=="y") qplot(value,data=dat.m.y, geom="bar", origin=-0.05, xlim=c(48,101),ylim=c(0,75), facets=variable~.,main="")+ xlab("Value")+ ylab("Frequency")+ theme(legend.position="none")+ stat_bin(aes(label = sprintf("%.01f", (..count../288)*100)),size=2.5,color="red", vjust=-0.5, angle=0, geom="text") __END__ What I wan't to do is to get rid of the barplot labels when the value in red is 0.0. How can I go about it? I tried this but it won't work stat_bin(aes(label = sprintf("%.01f", (..count../288)*100)),size=ifelse(dat$m.y>0,2.5,0),color="red", vjust=-0.5, angle=0, geom="text") ______________________________________________ R-help@r-project.org mailing list 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.