Hi Paul,

Thanks for the answer. I temporarily did it with the subplot function from the TeachingDemos package but I like this version much better.

Best,
Victor.

Paul Hiemstra wrote:
Victor Homar wrote:
Dear R users and helpers,

I'm trying to find an example of a histogram plot as an inset (upper right or left corner) of another histogram.

Anyone has an example of that?

Thanks for your help,

Víctor.

Hi,

You can use the histogram function from the lattice package (standard in R) in combination with the print statement. Example:

library(lattice)
h = histogram(cars$speed)
h2 = histogram(cars$speed, xlab = "", ylab="")
print(h, more = T)
print(h2, position = c(.05,.65,.5,.95))

The position argument in print gives the bounding box for the lattice object. The coordinate system is c(x1,y1,x2,y2) where (x1,y1) is the bottom left corner and (x2,y2) is the top right corner. The coordinate system runs from (0,0) in the bottom left corner to (1,1) in the top right corner.

hth and cheers,
Paul
--
-----------------------------------------------------------------------
Víctor Homar Santaner
Grup de Meteorologia

Edif. Mateu Orfila                      Tel: +34 971 17 1376
Universitat de les Illes Balears        Fax: +34 971 17 3426
07122 Palma de Mallorca (SPAIN)         Email: [EMAIL PROTECTED]

             Knowledge is contagious. Infect truth.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to