Monday, January 21, 2013

How to plot two or more variables on the same graph in R

If you want to plot two or more variables in the same graph in R, use the following code:
First plot one variable using the standard plot command.
The second variable and every next one you can place on the graph using the points command.
The graph bellow was made using the following code:

> plot(x, main="Upregulated genes, RN vs KD, p<0.05", xlab="Fold change", ylab="Number of genes", col="red", xaxt='n', type ="b")
> points(y, col="blue", type="b")
> fold.change <- c("4","3","2","1.5","1.2","all")

> axis(side = 1, at=1:6, labels = fold.change, tck = -0.02)
> mtext("Data with filtering RPKM>1 in blue")









No comments:

Post a Comment