ggplot2 - R ggplot geom_jitter duplicates outlier -


q1. plotting dataset using ggplot's geom_boxplot. however, when trying plot data points using geom_jitter(), outlier have in data duplicated. other data points fine. problem?

sample code:

peakperiod_24h <- c (31.05820, 23.83500, 24.36254, 25.31609, 24.21623, 23.90320)  condition <- rep("hl",6) data_hl <- data.frame(condition, peakperiod_24h) p <- ggplot(data_hl, aes(x=condition, y=peakperiod_24h, fill=condition)) p + geom_boxplot()+   geom_jitter(width = 0.3)+   theme_bw()+   coord_flip()+   geom_hline(aes(yintercept=24.18), colour="brown1", linetype="dotted", size = 1.4)+   scale_y_continuous(limits=c(), name = "period length")+   ggtitle("boxplots\nhabitual light")+   scale_fill_manual(values = c("gray60"))+   theme(plot.title = element_text(size=14, face="bold", vjust = .5),     axis.title.y = element_blank(),     axis.text.y = element_blank(),     axis.title.x = element_text(size=12, face = "bold"),     axis.text.x = element_text(size = 10, face = "bold", colour = "gray20"))+   guides(fill=false) 

enter image description here

thanks!

try

ggplot(data_hl, aes(x=condition, y=peakperiod_24h, fill=condition)) +    geom_boxplot(outlier.shape = na) +     geom_jitter(width = 0.3)  

the outlier doubled, because plotted geom_boxplot (unless specify don't want plot points outliers) , time geom_jitter.

and second question, can use

geom_jitter(width = 0.3, aes(color=i(c("black", "blue")[code+1l])))  

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -