[R] figure with inset
Gregory Snow
Greg.Snow at intermountainmail.org
Thu Dec 8 17:18:05 CET 2005
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
> subplot( plot(x,y), 1,9000, hadj=0, vadj=1)
See the help on subplot for more examples.
--
Gregory L. Snow Ph.D.
Statistical Data Center, IHC
greg.snow at ihc.com
(801) 408-8111
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> Pascal.Niklaus at unibas.ch
> Sent: Tuesday, December 06, 2005 2:44 AM
> To: r-help at 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
> R-help and other sources but not found a solution.
>
> 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 at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list