That’s pretty trivial but I was quite happy to find it within my drafts, as it’s actually a pain to find within the R documentation. When drawing several times over a plot (to insert data from several sources), it’s often not possible to have a data source cover all the value range from all combined other data sources. So to obtain a large enough plot area, you need to manually set it’s size… This is realized simply using the xlim and ylim parameters:
plot(xlim=c(min,max),ylim=c(min,max))
Note, however, that the “x” parameter is mandatory (but can be an empty vector), so a working command would be:
plot(x=c(),xlim=c(1,1000),ylim=c(0.01,0.55),type=”n”);
Here is a sample usage where I first set up the plot area with no data, then draw some lines of different colors:
plot(x=c(),xlim=c(1,1000),ylim=c(0.01,0.55),type=”n”);
lines(nObsToTest,avg_error005C,type=”l”,col=”#444444″);
lines(nObsToTest,avg_error005W,type=”l”,col=”#994444″);
lines(nObsToTest,avg_error001W,type=”l”,col=”#999944″);
lines(nObsToTest,avg_error001C,type=”l”,col=”#449944″);
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.