Hello R Studio Community!
I have data where I want to plot in the x-direction by 2 variables -- SN (serial number) and date.
When I plot with date on the x-axis all is well, and SN on the X-axis displays in groups like I want:
except the groups of points in the 2nd plot use position=position_jitter(seed=42) which is random, and what I need is for the groups of points in the SN plot to displayed in date order.
Is there a way to get secondary sorting/grouping? That is, the 2nd plot, except with the points displayed in time order instead of randomly jittered?
My plotting code looks like this: (note that "color=" doesn't work, I haven't cracked that yet either)
p<-ggplot(ds_filtered,
aes_string(
x = plot.obj$xVar,
y = plot.obj$yVar,
color = factor(ds_filtered$Run) # let type determine plotting
))
p<-p+ geom_point(color='blue',alpha=0.5, position=position_jitter(seed=42)) +
geom_hline(yintercept=usl, color="red") +
geom_hline(yintercept=lsl, color="green") +
scale_x_discrete(guide = guide_axis(check.overlap = TRUE))+
theme(axis.text.x = element_text(angle=90))
Thank you very kindly!
Andy