I have the following code that aligns the two graphs. Problem is that in .pdf it gives me it x-axis (0-100) is broken down into 0-20, 20-40..and so on. I wonder if there is for it to display the x-axis (and y-axis) in more detail than that. I'd appreciate your input -- pdf(file="VECTOR & ICA ALIGNMENT.pdf", height=5, width=5) par(oma=c(4,4,4,4),mar=c(2,2,2,2),mgp=c(1.8,0.1.8,0),mfrow=c(1,1)) vector <- read.table(file=paste("a_i_u_100.TXT",sep="")) plot(test$V2,test$V1,xlim=c(1,100),ylim=c (-1,10),xlab="TRs",ylab="amplitude",col="blue",type="l") ica <- read.table(file=paste("ica_100.TXT",sep="")) lines(test$V2,test$V1, col="red") title ("VECTOR & ICA ALIGNMENT") dev.off()
Philipp Pagel
2009-Sep-24 07:13 UTC
[R] Stretch the x-axis for better alignment comparison
On Wed, Sep 23, 2009 at 11:25:23AM -0700, Maggie wrote:> I have the following code that aligns the two graphs. > Problem is that in .pdf it gives me it x-axis (0-100) is broken down > into 0-20, 20-40..and so on. > I wonder if there is for it to display the x-axis (and y-axis) in more > detail than that.Without the necessary data I canot directly reproduce your example but have a look at this for a start: plot(0:10) axis(1, seq(0,10,0.2), labels=F) You may also want to use xaxt='n' in the plot command and then construct use axis to build the axis the way you want it. If reading out data from the graph is a concern, you may also want to look at the grid() command. cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/
On 09/24/2009 04:25 AM, Maggie wrote:> I have the following code that aligns the two graphs. > Problem is that in .pdf it gives me it x-axis (0-100) is broken down > into 0-20, 20-40..and so on. > I wonder if there is for it to display the x-axis (and y-axis) in more > detail than that. > I'd appreciate your input -- > > pdf(file="VECTOR& ICA ALIGNMENT.pdf", height=5, width=5) > par(oma=c(4,4,4,4),mar=c(2,2,2,2),mgp=c(1.8,0.1.8,0),mfrow=c(1,1)) > > vector<- read.table(file=paste("a_i_u_100.TXT",sep="")) > plot(test$V2,test$V1,xlim=c(1,100),ylim=c > (-1,10),xlab="TRs",ylab="amplitude",col="blue",type="l") > ica<- read.table(file=paste("ica_100.TXT",sep="")) > lines(test$V2,test$V1, col="red") > title ("VECTOR& ICA ALIGNMENT") > > dev.off() >Hi Maggie, The axis function defaults to fairly spaced-out labels, and will omit labels if they are too crowded. You can get around that by specifying that the x-axis (xaxt="n") or y-axis(yaxt="n") are not drawn by plot and then adding one or both later. If you have the crowded axis problem, have a look at the staxlab function in the plotrix package. Jim