Sunday, September 11, 2011

R subplot() with multiple lines

I have recently used the subplot() function of the TeachingDemos library for R: I wanted to create a simple embedded chart with multiple lines on it. The trick was to create a simple function that prepares the whole plot and pass it to the subplot() function to execute as shown below:


> x <- function() { plot(1:3); lines(3:1) }
> x()
> plot(1:10)
> subplot(x(), 5, 5)

No comments:

Post a Comment