Easiest way to accomplish your goal is to add this to your plot() call:
Code:
[COLOR="RoyalBlue"]yaxt="n"[/COLOR]
Then use the axis() function with your specific requirements:
Code:
axis(2, at=c(0, 500, 1000));
Code:
gene_lens <- data.frame("gene"=c(100,500,750,900), "control"=c(10,50,240,890), "IP"=c(110,240,830,15)); par("lend"="butt"); plot(gene_lens$gene, gene_lens$control, type='h', xlab='base position', ylim=c(0,1000), ylab='read depth', col="skyblue3", [COLOR="RoyalBlue"]yaxt="n"[/COLOR], lwd=6); par("new"=TRUE); plot(gene_lens$gene, gene_lens$IP, type='h', xlab='', ylim=c(0,1000), ylab='', col="red", [COLOR="RoyalBlue"]yaxt="n"[/COLOR], xaxt="n", lwd=2); atN <- c(0, 500, 1000); axis(2, at=atN, labels=format(atN, big.mark=","), las=2);
Lastly, I'm not sure I'm familiar with this type of plot, but it seems like you're going for a sort of bar chart? If so, you may try the barplot2() function in the gplots package, something like this:
Code:
library(gplots); barplot2(t(as.matrix(gene_lens[,c("control", "IP")])), beside=TRUE, names.arg=gene_lens$gene, xlab='base position', col=c("seagreen", "orange"), yaxt="n", ylim=c(0,1000)); axis(2, las=2, at=c(0,500,1000));
Leave a comment: