[R] Main title in a multiple display of graphs
Peter Ehlers
ehlers at ucalgary.ca
Fri Mar 11 04:18:44 CET 2011
On 2011-03-10 13:37, Marcos Prunello wrote:
> Hello!
>
> I want to display four xyplots in the same window (sorry if I don't use the propers words, but my English is rude)
>
> I know that if I use plot(y~x) then
>
> x=(1:100)
> y=(1:100)
> par(mfrow=c(2,2))
> plot(y~x)
> plot(y~x)
> plot(y~x)
> plot(y~x)
>
> would give what I want, but this is not the case because I need the functions of xyplot.
>
> So I did the following:
>
> plot.new()
> title(main="Tasas de Mortalidad por 100.000 habitantes",outer=TRUE)
> print(xyplot(y~x), position=c(0,0.5,0.5,1), more=T)
> print(xyplot(y~x), position=c(0.5,0.5,1,1), more=T)
> print(xyplot(y~x), position=c(0,0,0.5,0.5), more=T)
> print(xyplot(y~x), position=c(0.5,0,1,0.5), more=T)
>
> In the output the title is not complete, a part of the letters only is seen.
> I searched how to solve this problem but nothing worked.
I don't know why you need xyplot, but an easy solution
would be to create a factor variable and then plot
y ~ x conditional on the factor:
dat <- data.frame(x = rep(x, 4), y = rep(y, 4), g = gl(4, 100))
xyplot(y ~ x | g, data = dat, main = "whatever you want")
If you want separate axes with possibly modified interpanel
spacing and with/without the strips:
xyplot(y ~ x | g, data = dat
,main = "whatever you want"
,strip = FALSE # remove if you want the strips
,between = list(x = 1, y = 2)
,scales = list(relation = 'free', rot = 0)
)
Another possibility might be the latticedl package, but I
haven't yet used it.
Peter Ehlers
>
> I read about "figure margins", proved with different things like oma, omi, mar, mai,layout, par, mfcol, mfrow,mtext,title...
>
> I hope you can guide me!
>
> Thanks a lot!
>
> Marcos (Argentina)
>
>
>
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list