Skip to content
Prev 319576 / 398506 Next

column and line graphs in R

When you send data, use dput() to send them. It is much more easy for 
people who want to help you.
Here is an example. I am not sure if it is what you want but you can 
play with the code.
Sincerely

Marc

fungal <- structure(list(rel.abund = c(0.003, 0.029, 0.033, 0.023, 0.009,
0.042, 0.069, 0.059, 0.034, 0.049, 0.084, 0.015, 0.059, 0.032,
0.142, 0.031, 0.034, 0.01, 0.011, 0.004, 0.034, 0.182), rel.freq = c(0.083,
0.167, 0.167, 0.083, 0.083, 0.25, 0.083, 0.167, 0.083, 0.083,
0.333, 0.083, 0.083, 0.167, 0.25, 0.083, 0.083, 0.083, 0.083,
0.083, 0.333, 0.417)), .Names = c("rel.abund", "rel.freq"),
class = "data.frame", row.names = c("MOTU2",
"MOTU4", "MOTU6", "MOTU7", "MOTU9", "MOTU11", "MOTU14", "MOTU16",
"MOTU17", "MOTU18", "MOTU19", "MOTU20", "MOTU21", "MOTU22", "MOTU23",
"MOTU24", "MOTU25", "MOTU29", "MOTU30", "MOTU33", "MOTU36", "MOTU34"
))

premar <- par("mar")
par(mar=c(5,4,4,4)+0.1)

plot(fungal[,1], type="h", lwd=20, lend=2, bty="n", xlab="", 
ylab="Relative abundance", xaxt="n", ylim=c(0,0.2))
par(xpd=TRUE)
segments(-2.5, 0.01, -2.5, 0.03, lwd=20, lend=2, col="black")

par(new=TRUE)
plot(fungal[,2], type="p", bty="n", pch=16, col="red", axes=FALSE, 
xlab="", ylab="", main="", ylim=c(0,0.5))
axis(1, at=1:length(rownames(fungal)), labels=rownames(fungal), las=2)
axis(4)
mtext("Relative frequency", side=4, line=3)
points(25.6, 0.1, pch=16, col="red")

par(mar=premar)


Le 14/03/13 15:40, Gian Maria Niccol? Benucci a ?crit :