r - Using symbols to draw lines rather than line type -



r - Using symbols to draw lines rather than line type -

i have diet info of 7 monkeys details proportion of each diet item in each monkeys diet se. info included here.

data <- structure(list(monkeyid = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 4l, 4l, 4l, 4l, 4l, 4l, 4l, 4l, 4l, 5l, 5l, 5l, 5l, 5l, 5l, 5l, 5l, 5l, 6l, 6l, 6l, 6l, 6l, 6l, 6l, 6l, 6l, 7l, 7l, 7l, 7l, 7l, 7l, 7l, 7l, 7l), .label = c("p06", "p07", "p08", "p09", "p10", "p12", "p13"), class = "factor"), diet = structure(c(3l, 2l, 8l, 1l, 5l, 4l, 6l, 7l, 9l, 3l, 2l, 8l, 1l, 5l, 4l, 6l, 7l, 9l, 3l, 2l, 8l, 1l, 5l, 4l, 6l, 7l, 9l, 3l, 2l, 8l, 1l, 5l, 4l, 6l, 7l, 9l, 3l, 2l, 8l, 1l, 5l, 4l, 6l, 7l, 9l, 3l, 2l, 8l, 1l, 5l, 4l, 6l, 7l, 9l, 3l, 2l, 8l, 1l, 5l, 4l, 6l, 7l, 9l), .label = c("apple", "bird", "cherry", "goats", "orange", "porcupine", "raccoon", "smchildren", "smmamm"), class = "factor"), obsprop = c(0.333333333, 0, 0, 0.033333333, 0.366666667, 0.166666667, 0.033333333, 0.066666667, 0, 0, 0, 0, 0, 0.684931507, 0.315068493, 0, 0, 0, 0, 0, 0, 0.022727273, 0.840909091, 0.113636364, 0, 0, 0.022727273, 0, 0, 0, 0.016666667, 0.916666667, 0.066666667, 0, 0, 0, 0, 0.016129032, 0.032258065, 0.080645161, 0.790322581, 0.064516129, 0, 0, 0.016129032, 0.083333333, 0, 0, 0, 0.791666667, 0.125, 0, 0, 0, 0.105263158, 0, 0, 0, 0.657894737, 0.210526316, 0, 0, 0.026315789), bootsd = c(0.086106917, 0, 0, 0.032505407, 0.088036303, 0.067629445, 0.033002128, 0.046190006, 0, 0, 0, 0, 0, 0.05399944, 0.05399944, 0, 0, 0, 0, 0, 0, 0.022101535, 0.055554128, 0.04806202, 0, 0, 0.022399649, 0, 0, 0, 0.016603534, 0.03591038, 0.032417222, 0, 0, 0, 0, 0.016058474, 0.022618108, 0.034249235, 0.051625307, 0.03101898, 0, 0, 0.015862183, 0.055436816, 0, 0, 0, 0.082385021, 0.067258445, 0, 0, 0, 0.049480715, 0, 0, 0, 0.076734249, 0.066770967, 0, 0, 0.026230342)), .names = c("monkeyid", "diet", "obsprop", "bootsd"), class = "data.frame", row.names = c(na, -63l))

and

> head(data) monkeyid diet obsprop bootsd 1 p06 cherry 0.33333333 0.08610692 2 p06 bird 0.00000000 0.00000000 3 p06 smchildren 0.00000000 0.00000000 4 p06 apple 0.03333333 0.03250541 5 p06 orange 0.36666667 0.08803630 6 p06 goats 0.16666667 0.06762944

with code

require(ggplot2) pd <- position_dodge(0.5) colorblind <- c("#999999", "#e69f00", "#56b4e9", "#009e73", "#f0e442", "#0072b2", "#d55e00", "#cc79a7") fig <- ggplot(data)+ geom_point(aes(x=diet, y=obsprop ,color=monkeyid),position = pd, size = 2.75)+ geom_errorbar(aes(x=diet, ymin=(obsprop - bootsd), ymax=(obsprop + bootsd),colour=monkeyid), position = pd, cex =1.25)+ ylab("proportion of prey in diet")+ theme(legend.position = "bottom")+ theme_bw()+ scale_colour_manual(values =colorblind)+ scale_linetype_manual(values=c(1,2,3,4,5,6,7))+ labs(color="cougar id") fig

i can generate figure.

problem: color figures expensive. need distinguish between individual monkeys without color. mapping monkeyid linetype not produce discernible results (below).

fig <- ggplot(data)+ geom_point(aes(x=diet, y=obsprop ,type = monkeyid),position = pd, size = 2.75)+ geom_errorbar(aes(x=diet, ymin=(obsprop - bootsd), ymax=(obsprop + bootsd),lty = monkeyid), position = pd, cex =1.25)+ ylab("proportion of prey in diet")+ xlab("prey species")+ ggtitle("proportion of prey species in individual monkey diets")+ theme(legend.position = "bottom")+ theme_bw()+ scale_colour_manual(values =colorblind)+ scale_linetype_manual(values=c(1,2,3,4,5,6,7))+ labs(color="monkey id") fig

question possible utilize symbols 'draw' lines? example, can utilize open squares (or open circles, open triangles, closed squares, etc) depict line improve distinguishes between individuals?

a stylized , simplified version of looking (for goats only) this:

**edit:**i less interested in shape of point depicts each individual. more of import geom_errorbar each individual. if geom_errorbar unique each individual (like above) geom_point each individual less of import , left out ease interpenetration. in add-on ggplot shape palette can deal maximum of 6 discrete values because more 6 becomes hard discriminate

any thoughts on how accomplish goal or other ideas distinguish between individuals (without color) appreciated.

thanks in advance

the comments of ben bolker helpful. indeed, think changing desired outcome best alternative here. code below serves reply own question. guess posting own reply best way show post closed.

fig <- ggplot(data)+ geom_point(aes(x=diet, y=obsprop ,shape = monkeyid),position = pd, size = 3)+ geom_errorbar(aes(x=diet, ymin=(obsprop - bootsd), ymax=(obsprop + bootsd),lty = monkeyid), position = pd)+ ylab("proportion of prey in diet")+ xlab("prey species")+ ggtitle("proportion of prey species in individual monkey diets")+ theme(legend.position = "bottom")+ theme_bw()+ scale_linetype_manual(values=c(1,1,1,1,1,1,1))+ scale_shape_manual(values =c(19,6,15,5,1,8,17))+ labs(color="monkey id") fig

r ggplot2

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -