data<-sample_data
Temperature<-as.factor(data$Temperature)
#to change the orientation of the factor levels
data$ZT<-factor(data$ZT, levels = c( "T0", "T2", "T4", "T6", "T8", "T10", "T12", "T14", "T16", "T18", "T20", "T22") )
ZT<-data$ZT
#to change the orientation of the factor levels
data$Genotype<-factor(data$Genotype, levels =c("Scarlett","S42-IL107","S42-IL176"))
Genotype<-data$Genotype
co1 <-data$co1
SD<-data$co1_sd
ggplot(data, aes(x= ZT,y=co1, group=Temperature, shape=Temperature, colour=Temperature)) +
geom_errorbar(aes(ymin=co1-SD, ymax=co1+SD), width=.7, size=.7)+
geom_line(aes(colour=Temperature), size=1.1)+
geom_point(aes(shape=Temperature),size=4)+
scale_color_manual(values=c("turquoise3","indianred2"))+
ylab("HvCO1 normalised expression")+
xlab(NULL)+
facet_wrap(~ Genotype,)
I am using this script to create facetted plot in ggplot2, sometimes script works fine but often it happens that data points get shuffled between the factor levels on one facet or between the facets. at the moment standard error bars are shuffled instead of data points. can somebody tell me why is this occurring?
here i compared this with excel graph on the same data. error bars of facet 2 and three.
structure(list(Genotype = structure(c(3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = c("S42-IL107", "S42-IL176", "Scarlett"), class = "factor"),
Temperature = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L), .Label = c("20°C", "28°C"), class = "factor"),
ZT = structure(c(1L, 7L, 10L, 11L, 12L, 2L, 3L, 4L, 5L, 6L,
8L, 9L, 1L, 7L, 10L, 11L, 12L, 2L, 3L, 4L, 5L, 6L, 8L, 9L,
1L, 7L, 10L, 11L, 12L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 5L, 6L,
8L, 9L, 1L, 7L, 10L, 11L, 12L, 2L, 3L, 4L, 1L, 7L, 10L, 11L,
12L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 1L, 7L, 10L, 11L, 12L, 2L,
3L, 4L, 5L, 6L, 8L, 9L), .Label = c("T0", "T10", "T12", "T14",
"T16", "T18", "T2", "T20", "T22", "T4", "T6", "T8"), class = "factor"),
co1 = c(0.004047961, 0.002880266, 0.001519785, 0.000667166,
0.000722255, 0.001466025, 0.004227897, 0.005888254, 0.007957774,
0.007576948, 0.005425386, 0.006893992, 0.005856547, 0.002997377,
0.001162904, 0.000576041, 0.000504455, 0.000508026, 0.001192632,
0.002094363, 0.005691455, 0.005918894, 0.007556918, 0.007736937,
0.007104176, 0.00584571, 0.002929043, 0.001618641, 0.002028418,
0.003404469, 0.010245418, 0.011297415, 0.009594296, 0.010923272,
0.01016621, 0.006077751, 0.005442749, 0.005538876, 0.006345497,
0.005632192, 0.007438102, 0.005501253, 0.002168485, 0.00111058,
0.000951645, 0.001391862, 0.001377207, 0.003435266, 0.00514792,
0.004080233, 0.002140552, 0.001426237, 0.002272299, 0.004213762,
0.008400302, 0.008992385, 0.006691724, 0.008404276, 0.007611373,
0.005460758, 0.001109314, 0.000732904, 0.000268885, 0.000244801,
0.000280516, 0.00077615, 0.001283453, 0.003493581, 0.004653499,
0.002507832, 0.002864612, 0.001727669), co1_sd = c(0.00029648,
0.000613192, 0.000221025, 0.000224196, 0.000223837, 0.00044702,
0.000706827, 0.001155351, 0.000232335, 0.00032364, 0.000602965,
0.001063606, 0.000923741, 0.000410751, 0.000150132, 0.000303137,
0.000104852, 0.000114863, 0.000569747, 0.00063052, 0.003203487,
0.001025025, 0.00301162, 0.003984255, 0.001973626, 0.001211777,
0.000226229, 0.000558652, 0.000615758, 0.000770557, 0.000956524,
0.001361853, 0.001474607, 0.002037219, 0.001628115, 0.002383452,
0.000147587, 0.000699657, 0.001651883, 0.00174892, 0.001190546,
0.000660793, 0.000635082, 0.000207585, 0.000226194, 0.000328652,
0.000640193, 0.001926859, 0.00069947, 0.000505254, 0.000178241,
0.000205647, 0.000348112, 0.000289324, 0.003999638, 0.001073981,
0.000260649, 0.001288045, 0.001187429, 0.000991558, 9.29063e-05,
4.65434e-05, 2.95757e-05, 5.16943e-05, 0.000144199, 0.000470742,
0.000250978, 0.000972389, 0.00049583, 0.000280404, 0.000529082,
0.000287902)), .Names = c("Genotype", "Temperature", "ZT",
"co1", "co1_sd"), class = "data.frame", row.names = c(NA, -72L
))