Dear all,
I'm trying to produce two dotcharts side-by-side within a Sweave
document. When I'm compiling this example:
\documentclass{article}
\begin{document}
<<fig=T,width=8,height=4>>par(mfrow = c(1, 2), cex = 0.7)
for(i in 1:2) dotchart(1:10)
@
<<fig=T,width=8,height=4>>par(mfrow = c(1, 2), cex = 0.7)
for(i in 1:2) hist(1:10)
@
<<fig=T,width=8,height=4>>par(mfrow = c(1, 2), cex = 0.7)
for(i in 1:2) plot(1:10)
@
\end{document}
I obtain the following:
http://pbil.univ-lyon1.fr/members/lobry/mini.pdf
that is with the second dotchart (on the right) smaller than the
one on the left. I do not have the same problem with
hist() or plot().
Any idea of what should I do for my two dotcharts to be of
the same size?
Best,
> sessionInfo()
R version 2.4.0 (2006-10-03)
powerpc-apple-darwin8.7.0
locale:
fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8
attached base packages:
[1] "methods" "stats" "graphics"
"grDevices" "utils" "datasets"
[7] "base"
--
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/
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/
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?