[R] Size problem with two dotcharts side by side

Martin Maechler maechler at stat.math.ethz.ch
Tue Oct 24 18:12:56 CEST 2006


>>>>> "jim" == jim holtman <jholtman at gmail.com>
>>>>>     on Fri, 20 Oct 2006 08:53:08 -0400 writes:

    jim> It appears that dotchart is not restoring some of the 'par'
    jim> parameters.  It only saves some specific one:

Indeed.
Thank you, Jim and Jean, for the well reproducible example.

This will be fixed in future versions of R.
Martin Maechler, ETH Zurich

    >> oldpar <- par(no.readonly=TRUE)
    >> dotchart(1:10, cex = 0.7) # first call
    >> newpar <- par(no.readonly=TRUE)
    >> identical(oldpar,newpar)
    jim> [1] FALSE
    >> 
    >> 
    >> lapply(names(oldpar), function(x)if (!identical(oldpar[[x]], newpar[[x]])) cat(x,'\n'))
    jim> mar
    jim> usr
    jim> xaxp
    jim> yaxp
    >> 
    >> 
    >> dotchart(1:10, cex = 0.7) # second call
    >> oldpar <- par(no.readonly=TRUE)
    >> identical(oldpar,newpar)
    jim> [1] TRUE
    >> 
    >> lapply(names(oldpar), function(x)if (!identical(oldpar[[x]], newpar[[x]])) cat(x,'\n'))
    >> 
    >> 


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


    jim> 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> -- 
    jim> Jim Holtman
    jim> Cincinnati, OH
    jim> +1 513 646 9390

    jim> What is the problem you are trying to solve?

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

>>>>> "jim" == jim holtman <jholtman at gmail.com>
>>>>>     on Fri, 20 Oct 2006 08:53:08 -0400 writes:

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


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


    jim> On 10/19/06, Jean lobry <lobry at biomserv.univ-lyon1.fr>
    jim> 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> -- Jim Holtman Cincinnati, OH +1 513 646 9390

    jim> What is the problem you are trying to solve?

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



More information about the R-help mailing list