![]() ![]() When all variables are between-subjects, it is straightforward to plot standard error or confidence intervals. 9 )) xlab ( "Dose (mg)" ) ylab ( "Tooth length" ) scale_fill_hue ( name = "Supplement type", # Legend label, use darker colorsīreaks = c ( "OJ", "VC" ), labels = c ( "Orange juice", "Ascorbic acid" )) ggtitle ( "The Effect of Vitamin C on\nTooth Growth in Guinea Pigs" ) scale_y_continuous ( breaks = 0 : 20 * 4 ) theme_bw () Geom_errorbar ( aes ( ymin = len - se, ymax = len se ), size =. Ggplot ( tgc2, aes ( x = dose, y = len, fill = supp )) geom_bar ( position = position_dodge (), stat = "identity", colour = "black", # Use black outlines, The points are drawn last so that the white fill goes on top of the lines and error bars. 1, position = pd ) geom_line ( position = pd ) geom_point ( position = pd, size = 3 )Ī finished graph with error bars representing the standard error of the mean might look like this. ![]() Ggplot ( tgc, aes ( x = dose, y = len, colour = supp, group = supp )) geom_errorbar ( aes ( ymin = len - ci, ymax = len ci ), colour = "black", width =. 1, position = pd ) geom_line ( position = pd ) geom_point ( position = pd ) # Black error bars - notice the mapping of 'group=supp' - without it, the error Ggplot ( tgc, aes ( x = dose, y = len, colour = supp )) geom_errorbar ( aes ( ymin = len - ci, ymax = len ci ), width =. 1, position = pd ) geom_line ( position = pd ) geom_point ( position = pd ) # Use 95% confidence interval instead of SEM Ggplot ( tgc, aes ( x = dose, y = len, colour = supp )) geom_errorbar ( aes ( ymin = len - se, ymax = len se ), width =. ![]() Pd <- position_dodge ( 0.1 ) # move them. 1 ) geom_line () geom_point () # The errorbars overlapped, so use position_dodge to move them horizontally ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |