[R] little subplot in corner

Henrique Dallazuanna wwwhsd at gmail.com
Mon Mar 24 12:32:24 CET 2008


Perhaps:

set.seed(24032008)
plot(rnorm(10),type="l",col="red")
grid()
front=c(0.5, .97, 0.5, .97)
par(fig=front, new=T)#, bg="skyblue" does not work
set.seed(24032008)
x <- rnorm(4)
plot(x,type="l",col="blue",xlab="",ylab="", bg="yellow")
rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col="yellow")
lines(x, col="blue")

On 24/03/2008, Thomas Steiner <finbref.2006 at gmail.com> wrote:
> Henrique,
>
>  Although your solution is perfect, I had later a problem with setting
>  the background. Perhaps you know how to get this as well:
>
>  set.seed(24032008)
>  plot(rnorm(10),type="l",col="red")
>  grid()
>  front=c(0.5, .97, 0.5, .97)
>  par(fig=front, new=T)#, bg="skyblue" does not work
>  rec=c(par("usr")[1]+(par("usr")[2]-par("usr")[1])*front[1],
>  par("usr")[3]+(par("usr")[4]-par("usr")[3])*front[3],
>  par("usr")[1]+(par("usr")[2]-par("usr")[1])*front[3],
>  par("usr")[1]+(par("usr")[2]-par("usr")[1])*front[4])
>  #rect(rec[1],rec[2],rec[3],rec[4],col="yellow")
>  plot(rnorm(4),type="l",col="blue",xlab="",ylab="")
>
>  as you can see it would be good to be able to set the background of
>  the subfigure. as the par(bg=) does not work, I tried to plot a
>  rectangle. Just uncomment the send-last line and you will see that the
>  original plot disappears after some strange rectangle is drawn.
>
>  If you have any idea again, it would be evry much appreaciated to let me know.
>
> Thomas
>
>
>  PS: to see my first attempts, look at
>  http://commons.wikimedia.org/wiki/Image:Eurusd-id.png
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list