[R] Size problem with two dotcharts side by side

jim holtman jholtman at gmail.com
Fri Oct 20 14:53:08 CEST 2006


It appears that dotchart is not restoring some of the 'par'
parameters.  It only saves some specific one:
> oldpar <- par(no.readonly=TRUE)
> dotchart(1:10, cex = 0.7) # first call
> newpar <- par(no.readonly=TRUE)
> identical(oldpar,newpar)
[1] FALSE
>
>
> lapply(names(oldpar), function(x)if (!identical(oldpar[[x]], newpar[[x]])) cat(x,'\n'))
mar
usr
xaxp
yaxp
>
>
> dotchart(1:10, cex = 0.7) # second call
> oldpar <- par(no.readonly=TRUE)
> identical(oldpar,newpar)
[1] TRUE
>
> lapply(names(oldpar), function(x)if (!identical(oldpar[[x]], newpar[[x]])) cat(x,'\n'))
>
>


After the first call, then they will be identical for subsequent calls.


On 10/19/06, Jean lobry <lobry at biomserv.univ-lyon1.fr> wrote:
> Dear list,
>
> I'm answering to my own question.
>
> I found that it is possible to reproduce the behavior in the interactive
> mode this way:
>
> quartz() # start a new device (I have also tried with x11() under Linux
>          # and windows() under windows with the same result.
> dotchart(1:10, cex = 0.7) # first call
> dotchart(1:10, cex = 0.7) # second call
>
> The plot region is smaller in the second call than in the first one,
> and then stable on further calls.
>
> I found that saving/retauring par("mar") allowed me to have the
> same plot region so that this Sweave code:
>
> \documentclass{article}
> \begin{document}
> <<fig=T,width=8,height=4>>=
> par(mfrow = c(1, 2), cex = 0.7)
> omar <- par("mar")
> for(i in 1:2){
> par(mar  = omar)
> dotchart(1:10)
> }
> @
> \end{document}
>
> gave me two dotcharts side by side without size problem:
> http://pbil.univ-lyon1.fr/members/lobry/mini2.pdf
>
> Best,
>
> Jean Lobry
>
>
> P.-S. I don't understand why I have to do that because the dotchart()
> function code starts with:
>
> opar <- par("mai", "cex", "yaxs")
> on.exit(par(opar))
>
> so that I was understanding that margins were restaured on exit.
> --
> Jean R. Lobry            (lobry at biomserv.univ-lyon1.fr)
> Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
> 43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
> allo  : +33 472 43 27 56     fax    : +33 472 43 13 88
> http://pbil.univ-lyon1.fr/members/lobry/
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list