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)
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
Post a Comment