# Re: [R] figure with inset

From: Gregory Snow <Greg.Snow_at_intermountainmail.org>
Date: Fri 09 Dec 2005 - 03:18:05 EST

There is a subplot command in the latest version of the TeachingDemos package (version 1.1 available today) that does what you want using traditional graphics (others have given suggestions using grid graphics). An example:

> x <- 0:10
> y <- x^4
> plot(x,y,xaxs='i',yaxs='i')
> subplot( plot(x,y,xaxs='i',yaxs='i',xlab='',ylab=''),
c(1,5),c(5000,9000))

Or

> tmp <- cnvrt.coords(x=c(.1,.5),c(.5,.9),input='plt')\$usr
> subplot( plot(x,y,xaxs='i',yaxs='i',xlab='',ylab=''), tmp)

Or

See the help on subplot for more examples.

```--
Gregory L. Snow Ph.D.
Statistical Data Center, IHC
greg.snow@ihc.com
(801) 408-8111

> -----Original Message-----

> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of
> Pascal.Niklaus@unibas.ch
> Sent: Tuesday, December 06, 2005 2:44 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] figure with inset
>
> I am trying to plot a figure within a figure (an inset that
> shows a closeup of part of the data set). I have searched
>
> What I would like to do is
>
> (1) produce a plot
> (2) specify a window that will be used for the next plot (in
> inches or using the coordinate system of the plot produced in (1)
> (3) overlay a new plot in the window specified under (2)
>
> The result would be:
>
> +----------------------+
> |                      |
> | first plot           |
> |       +--------+     |
> |       | inset  |     |
> |       +--------+     |
> |                      |
> +----------------------+
>
> Thank you for your help
>
> Pascal
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help