zoom in regions of graph in coord_polar

24 views
Skip to first unread message

Aaron Zhang

unread,
Apr 21, 2014, 11:13:17 AM4/21/14
to ggp...@googlegroups.com
Hi everyone, 

I am using polar coordinate to present my data. Because of the presence of a few outliers, my graph has extremely wide y scale. If I use scale_y_continuous(limit=c(0,20000)), it will remove some data, see the warning:

Warning message:
Removed 3 rows containing non-finite values (stat_boxplot). 

see the example:

##note the last value of value is far larger than the rest
value<-c(rnorm(19),5)
sample<-c("a","b","c","d")
data<-data.frame(sample,value)
library(ggplot2)
p<-ggplot(data)
##the scale is large to include the outlier in the graph
p+geom_boxplot(aes(x=sample,y=value))+coord_polar()
##if use scale_y_continuous(limit=c(-3,3)), there will be warning
p+geom_boxplot(aes(x=sample,y=value))+coord_polar()+scale_y_continuous(limit=c(-3,3))

Warning message:
Removed 1 rows containing non-finite values (stat_boxplot).

However, I cannot use coord_polar(ylim=c(-3,3)) as I would do in the cartesian coordinate. 
p+geom_boxplot(aes(x=sample,y=value))+coord_polar()+coord_polar(ylim=c(-3,3))

Error in coord_polar(ylim = c(-3, 3)) : unused argument (ylim = c(-3, 3))

I am wondering if there is a similar solution as in cartesian coordinate, which is using coord_cartesian(ylim=c(0,20000))

I appreciate your help!
Aaron
Reply all
Reply to author
Forward
0 new messages