Thursday, 15 July 2010

r - Adding lines to a qplot that don't cover whole axes -



r - Adding lines to a qplot that don't cover whole axes -

i want add together partial lines (dont expand whole plot) scatterplot. have 2 separate plots working this, can't figure out how bring together them together:

first plot -

p = qplot(x, y, data=data) + theme_bw() + theme(aspect.ratio=1) lines = data.frame(x = c(-2,-2,5), y = c(0,2,2))

second plot -

lines = data.frame(x = c(-2,-2,5), y = c(0,2,2)) base of operations = ggplot(lines, aes(x, y)) base of operations + geom_path(size = 1)

how overlay them? thanks.

can try:

p = qplot(x, y, data=data) + theme_bw() + theme(aspect.ratio=1) lines = data.frame(x = c(-2,-2,5), y = c(0,2,2)) p+geom_line(data = lines, aes(x=x, y=y))

taking illustration dataset mydf:

dept <- c("res","bankings","customer","legal","collection","business") yscore <- c(1,2,3,1,2,3) xscore <- c(2,1,3,1,2,4) mydf<-data.frame(dept,yscore,xscore) p = qplot(xscore, yscore, data=mydf) + theme_bw() + theme(aspect.ratio=1) lines = data.frame(x = c(-2,-2,5), y = c(0,2,2)) p+geom_line(data = lines, aes(x=x, y=y))

r ggplot2

No comments:

Post a Comment