Is their any process to improve jagged lines produced by geom_line() joining multiple points into smooth presentable lines in ggplot2?
lai.se <- structure(list(DOS = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L), .Label = c("D1", "D2", "D3"), class = "factor"),
DAS = c(31L, 84L, 113L, 132L, 160L, 35L, 82L, 108L, 126L,
146L, 37L, 83L, 94L, 113L, 134L), N = c(24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L), LAI = c(1.5879167,
4.3241667, 3.70375, 2.9704167, 0.1879167, 1.7679167, 3.7670833,
3.4104167, 2.7879167, 0.195, 1.3179167, 3.5233333, 3.1604167,
2.45875, 0.2758333), sd = c(0.4276323, 0.32478644, 0.34151596,
0.3338638, 0.09868611, 0.18551876, 0.38212767, 0.31431747,
0.35024189, 0.08836682, 0.16378616, 0.29256982, 0.28257326,
0.44131535, 0.09536733), se = c(0.08729008, 0.06629675, 0.06971165,
0.06814966, 0.02014422, 0.03786886, 0.07800148, 0.06415978,
0.07149283, 0.0180378, 0.03343271, 0.05972057, 0.05768002,
0.09008312, 0.01946677), ci = c(0.18057328, 0.13714529, 0.14420954,
0.14097832, 0.04167149, 0.0783377, 0.16135836, 0.13272463,
0.14789418, 0.03731404, 0.06916083, 0.1235414, 0.11932022,
0.18635113, 0.04027009)), .Names = c("DOS", "DAS", "N", "LAI",
"sd", "se", "ci"), class = "data.frame", row.names = c(NA, -15L
))
ggplot(lai.se, aes(x=DAS, y=LAI, colour=DOS)) +
geom_errorbar(aes(ymin=LAI-se, ymax=LAI+se), colour ="black", size =.5, width=1, position=position_dodge(.9)) +
geom_line() +
geom_point()+ theme_bw()
Lines created using these codes were very much pixelated zig-zag lines. Is their any way out to plot smoother "solid"
lines (not zig-zag looking)?
> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 LC_MONETARY=English_India.1252 LC_NUMERIC=C
[5] LC_TIME=English_India.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_0.9.2.1
loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 grid_2.14.2 gtable_0.1.1 labeling_0.1
[7] MASS_7.3-17 memoise_0.1 munsell_0.4 plyr_1.7.1 proto_0.3-9.2 RColorBrewer_1.0-5
[13] reshape2_1.2.1 scales_0.2.2 stringr_0.6.1 tools_2.14.2
I'm guessing you're trying to smooth a line. Is this in the ball park of what you're after?
ggplot(lai.se, aes(x=DAS, y=LAI, colour=DOS)) +
geom_errorbar(aes(ymin=LAI-se, ymax=LAI+se), colour ="black", size =.5, width=1, position=position_dodge(.9)) +
geom_smooth() +
geom_point()+ theme_bw()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With