Dear all, there seems to be a problem with displayed legends when a multiple figure environment is used, see the following example: par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) legend(-4,0.2,legend="curve",lty=1,col=4) On my machines the first time the command legend() is issued the legend box stretches over the curve. Subsequent calls to legend seems to produce a correct box instead. openSuse 11.0 platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status Patched major 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 language R version.string R version 2.8.1 Patched (2009-01-07 r47501) I see this on the same version of R on Windows VISTA 32 bit as well; I do not see this behaviour on a machine with R 2.8.0. Thank you, Simone -- ______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/
legend() in a multiple figure environment
10 messages · Simone Giannerini, Mathieu Ribatet, Martin Maechler +2 more
Dear Simone,
Did mean that the legend (text and/or box) overlap with the Normal
density? If so then I think there's no problem as the legend is placed
where you told R to do. And R won't check (for you) if it will overlap
or not with pre-existing graphical elements.
On my computer, I got the expected results - if I understood correctly
your issue though. For information:
R version 2.8.1 (2008-12-22)
Linux mathieu-laptop 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52
UTC 2008 i686 GNU/Linux (Ubuntu Intrepid)
Cheers,
Mathieu
Simone Giannerini a ?crit :
Dear all, there seems to be a problem with displayed legends when a multiple figure environment is used, see the following example: par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) legend(-4,0.2,legend="curve",lty=1,col=4) On my machines the first time the command legend() is issued the legend box stretches over the curve. Subsequent calls to legend seems to produce a correct box instead. openSuse 11.0 platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status Patched major 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 language R version.string R version 2.8.1 Patched (2009-01-07 r47501) I see this on the same version of R on Windows VISTA 32 bit as well; I do not see this behaviour on a machine with R 2.8.0. Thank you, Simone --
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/ ______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Institute of Mathematics Ecole Polytechnique F?d?rale de Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907
Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu Ribatet
<mathieu.ribatet at epfl.ch> wrote:
Dear Simone, Did mean that the legend (text and/or box) overlap with the Normal density?
no, I mean that the two legend() commands, which are identical in all but the y-coordinates, produce different results, namely boxes with different widths. Ciao Simone
If so then I think there's no problem as the legend is placed where you told R to do. And R won't check (for you) if it will overlap or not with pre-existing graphical elements. On my computer, I got the expected results - if I understood correctly your issue though. For information: R version 2.8.1 (2008-12-22) Linux mathieu-laptop 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008 i686 GNU/Linux (Ubuntu Intrepid) Cheers, Mathieu Simone Giannerini a ?crit :
Dear all, there seems to be a problem with displayed legends when a multiple figure environment is used, see the following example: par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) legend(-4,0.2,legend="curve",lty=1,col=4) On my machines the first time the command legend() is issued the legend box stretches over the curve. Subsequent calls to legend seems to produce a correct box instead. openSuse 11.0 platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status Patched major 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 language R version.string R version 2.8.1 Patched (2009-01-07 r47501) I see this on the same version of R on Windows VISTA 32 bit as well; I do not see this behaviour on a machine with R 2.8.0. Thank you, Simone --
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/ ______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
-- Institute of Mathematics Ecole Polytechnique F?d?rale de Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/
"SG" == Simone Giannerini <sgiannerini at gmail.com>
on Thu, 8 Jan 2009 14:08:17 +0100 writes:
SG> Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu
SG> Ribatet <mathieu.ribatet at epfl.ch> wrote:
>> Dear Simone,
>>
>> Did mean that the legend (text and/or box) overlap with
>> the Normal density?
SG> no, I mean that the two legend() commands, which are
SG> identical in all but the y-coordinates, produce
SG> different results, namely boxes with different widths.
I don't see that behavior at all, rather the two boxes have
identical dimensions for me.
What does dev.cur() say? if anything with "X11..." (as you are
on Linux), what does
str(X11.options())
give?
SG> Ciao
SG> Simone
>> If so then I think there's no problem as the legend is
>> placed where you told R to do. And R won't check (for
>> you) if it will overlap or not with pre-existing
>> graphical elements.
>>
>> On my computer, I got the expected results - if I
>> understood correctly your issue though. For information:
>>
>> R version 2.8.1 (2008-12-22) Linux mathieu-laptop
>> 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008
>> i686 GNU/Linux (Ubuntu Intrepid)
>>
>> Cheers, Mathieu
>>
>> Simone Giannerini a ?crit :
>>>
>>> Dear all,
>>>
>>> there seems to be a problem with displayed legends when
>>> a multiple figure environment is used, see the following
>>> example:
>>>
>>> par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4);
>>> legend(-4,0.3,legend="curve",lty=1,col=4)
>>> legend(-4,0.2,legend="curve",lty=1,col=4)
>>>
>>>
>>> On my machines the first time the command legend() is
>>> issued the legend box stretches over the
>>> curve. Subsequent calls to legend seems to produce a
>>> correct box instead.
>>>
>>> openSuse 11.0
>>>
>>> platform x86_64-unknown-linux-gnu arch x86_64 os
>>> linux-gnu system x86_64, linux-gnu status Patched major
>>> 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501
>>> language R version.string R version 2.8.1 Patched
>>> (2009-01-07 r47501)
>>>
>>> I see this on the same version of R on Windows VISTA 32
>>> bit as well; I do not see this behaviour on a machine
>>> with R 2.8.0.
>>>
>>> Thank you,
>>>
>>> Simone
>>> --
>>> ______________________________________________________
>>>
>>> Simone Giannerini Dipartimento di Scienze Statistiche
>>> "Paolo Fortunati" Universita' di Bologna Via delle belle
>>> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax:
>>> +39 051 232153 http://www2.stat.unibo.it/giannerini/
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>
-- Institute of Mathematics Ecole Polytechnique F?d?rale de
>> Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne
>> Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907
>>
>>
>>
______________________________________________________
SG> Simone Giannerini Dipartimento di Scienze Statistiche
SG> "Paolo Fortunati" Universita' di Bologna Via delle belle
SG> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax:
SG> +39 051 232153 http://www2.stat.unibo.it/giannerini/
SG> ______________________________________________
SG> R-devel at r-project.org mailing list
SG> https://stat.ethz.ch/mailman/listinfo/r-devel
On linux, I get
dev.cur()
null device
1
str(X11.options())
List of 15 $ display : chr "" $ width : num NA $ height : num NA $ pointsize : num 12 $ bg : chr "transparent" $ canvas : chr "white" $ gamma : num 1 $ colortype : chr "true" $ maxcubesize: num 256 $ fonts : chr [1:2] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*" "-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*" $ xpos : int NA $ ypos : int NA $ title : chr "" $ type : chr "cairo" $ antialias : num 1 thanks, Simone On Thu, Jan 8, 2009 at 2:39 PM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
"SG" == Simone Giannerini <sgiannerini at gmail.com>
on Thu, 8 Jan 2009 14:08:17 +0100 writes:
SG> Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu SG> Ribatet <mathieu.ribatet at epfl.ch> wrote:
>> Dear Simone, >> >> Did mean that the legend (text and/or box) overlap with >> the Normal density?
SG> no, I mean that the two legend() commands, which are SG> identical in all but the y-coordinates, produce SG> different results, namely boxes with different widths. I don't see that behavior at all, rather the two boxes have identical dimensions for me. What does dev.cur() say? if anything with "X11..." (as you are on Linux), what does str(X11.options()) give? SG> Ciao SG> Simone
>> If so then I think there's no problem as the legend is >> placed where you told R to do. And R won't check (for >> you) if it will overlap or not with pre-existing >> graphical elements. >> >> On my computer, I got the expected results - if I >> understood correctly your issue though. For information: >> >> R version 2.8.1 (2008-12-22) Linux mathieu-laptop >> 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008 >> i686 GNU/Linux (Ubuntu Intrepid) >> >> Cheers, Mathieu >> >> Simone Giannerini a ?crit :
>>> >>> Dear all, >>> >>> there seems to be a problem with displayed legends when >>> a multiple figure environment is used, see the following >>> example: >>> >>> par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); >>> legend(-4,0.3,legend="curve",lty=1,col=4) >>> legend(-4,0.2,legend="curve",lty=1,col=4) >>> >>> >>> On my machines the first time the command legend() is >>> issued the legend box stretches over the >>> curve. Subsequent calls to legend seems to produce a >>> correct box instead. >>> >>> openSuse 11.0 >>> >>> platform x86_64-unknown-linux-gnu arch x86_64 os >>> linux-gnu system x86_64, linux-gnu status Patched major >>> 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 >>> language R version.string R version 2.8.1 Patched >>> (2009-01-07 r47501) >>> >>> I see this on the same version of R on Windows VISTA 32 >>> bit as well; I do not see this behaviour on a machine >>> with R 2.8.0. >>> >>> Thank you, >>> >>> Simone >>> -- >>> ______________________________________________________ >>> >>> Simone Giannerini Dipartimento di Scienze Statistiche >>> "Paolo Fortunati" Universita' di Bologna Via delle belle >>> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: >>> +39 051 232153 http://www2.stat.unibo.it/giannerini/ >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>
>>
-- Institute of Mathematics Ecole Polytechnique F?d?rale de
>> Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne >> Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907 >> >> >>
--
______________________________________________________ SG> Simone Giannerini Dipartimento di Scienze Statistiche SG> "Paolo Fortunati" Universita' di Bologna Via delle belle SG> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: SG> +39 051 232153 http://www2.stat.unibo.it/giannerini/ SG> ______________________________________________ SG> R-devel at r-project.org mailing list SG> https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/
Now I got how to reproduce it, it has nothing to do with multiple figure environment but rather with figure resizing. Here it is: curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) # Now expand the figure to full screen legend(-4,0.2,legend="curve",lty=1,col=4) Simone On Thu, Jan 8, 2009 at 2:39 PM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
"SG" == Simone Giannerini <sgiannerini at gmail.com>
on Thu, 8 Jan 2009 14:08:17 +0100 writes:
SG> Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu SG> Ribatet <mathieu.ribatet at epfl.ch> wrote:
>> Dear Simone, >> >> Did mean that the legend (text and/or box) overlap with >> the Normal density?
SG> no, I mean that the two legend() commands, which are SG> identical in all but the y-coordinates, produce SG> different results, namely boxes with different widths. I don't see that behavior at all, rather the two boxes have identical dimensions for me. What does dev.cur() say? if anything with "X11..." (as you are on Linux), what does str(X11.options()) give? SG> Ciao SG> Simone
>> If so then I think there's no problem as the legend is >> placed where you told R to do. And R won't check (for >> you) if it will overlap or not with pre-existing >> graphical elements. >> >> On my computer, I got the expected results - if I >> understood correctly your issue though. For information: >> >> R version 2.8.1 (2008-12-22) Linux mathieu-laptop >> 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008 >> i686 GNU/Linux (Ubuntu Intrepid) >> >> Cheers, Mathieu >> >> Simone Giannerini a ?crit :
>>> >>> Dear all, >>> >>> there seems to be a problem with displayed legends when >>> a multiple figure environment is used, see the following >>> example: >>> >>> par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); >>> legend(-4,0.3,legend="curve",lty=1,col=4) >>> legend(-4,0.2,legend="curve",lty=1,col=4) >>> >>> >>> On my machines the first time the command legend() is >>> issued the legend box stretches over the >>> curve. Subsequent calls to legend seems to produce a >>> correct box instead. >>> >>> openSuse 11.0 >>> >>> platform x86_64-unknown-linux-gnu arch x86_64 os >>> linux-gnu system x86_64, linux-gnu status Patched major >>> 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 >>> language R version.string R version 2.8.1 Patched >>> (2009-01-07 r47501) >>> >>> I see this on the same version of R on Windows VISTA 32 >>> bit as well; I do not see this behaviour on a machine >>> with R 2.8.0. >>> >>> Thank you, >>> >>> Simone >>> -- >>> ______________________________________________________ >>> >>> Simone Giannerini Dipartimento di Scienze Statistiche >>> "Paolo Fortunati" Universita' di Bologna Via delle belle >>> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: >>> +39 051 232153 http://www2.stat.unibo.it/giannerini/ >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>
>>
-- Institute of Mathematics Ecole Polytechnique F?d?rale de
>> Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne >> Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907 >> >> >>
--
______________________________________________________ SG> Simone Giannerini Dipartimento di Scienze Statistiche SG> "Paolo Fortunati" Universita' di Bologna Via delle belle SG> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: SG> +39 051 232153 http://www2.stat.unibo.it/giannerini/ SG> ______________________________________________ SG> R-devel at r-project.org mailing list SG> https://stat.ethz.ch/mailman/listinfo/r-devel
-- ______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/
You can find the resulting graph here (produced under win Vista) http://www2.stat.unibo.it/giannerini/R/try.eps (produced under win Vista) platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 8.1 year 2008 month 12 day 22 svn rev 47281 language R version.string R version 2.8.1 (2008-12-22)
On Thu, Jan 8, 2009 at 3:29 PM, Simone Giannerini <sgiannerini at gmail.com> wrote:
Now I got how to reproduce it, it has nothing to do with multiple figure environment but rather with figure resizing. Here it is: curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) # Now expand the figure to full screen legend(-4,0.2,legend="curve",lty=1,col=4) Simone On Thu, Jan 8, 2009 at 2:39 PM, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
"SG" == Simone Giannerini <sgiannerini at gmail.com>
on Thu, 8 Jan 2009 14:08:17 +0100 writes:
SG> Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu SG> Ribatet <mathieu.ribatet at epfl.ch> wrote:
>> Dear Simone, >> >> Did mean that the legend (text and/or box) overlap with >> the Normal density?
SG> no, I mean that the two legend() commands, which are SG> identical in all but the y-coordinates, produce SG> different results, namely boxes with different widths. I don't see that behavior at all, rather the two boxes have identical dimensions for me. What does dev.cur() say? if anything with "X11..." (as you are on Linux), what does str(X11.options()) give? SG> Ciao SG> Simone
>> If so then I think there's no problem as the legend is >> placed where you told R to do. And R won't check (for >> you) if it will overlap or not with pre-existing >> graphical elements. >> >> On my computer, I got the expected results - if I >> understood correctly your issue though. For information: >> >> R version 2.8.1 (2008-12-22) Linux mathieu-laptop >> 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008 >> i686 GNU/Linux (Ubuntu Intrepid) >> >> Cheers, Mathieu >> >> Simone Giannerini a ?crit :
>>> >>> Dear all, >>> >>> there seems to be a problem with displayed legends when >>> a multiple figure environment is used, see the following >>> example: >>> >>> par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); >>> legend(-4,0.3,legend="curve",lty=1,col=4) >>> legend(-4,0.2,legend="curve",lty=1,col=4) >>> >>> >>> On my machines the first time the command legend() is >>> issued the legend box stretches over the >>> curve. Subsequent calls to legend seems to produce a >>> correct box instead. >>> >>> openSuse 11.0 >>> >>> platform x86_64-unknown-linux-gnu arch x86_64 os >>> linux-gnu system x86_64, linux-gnu status Patched major >>> 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 >>> language R version.string R version 2.8.1 Patched >>> (2009-01-07 r47501) >>> >>> I see this on the same version of R on Windows VISTA 32 >>> bit as well; I do not see this behaviour on a machine >>> with R 2.8.0. >>> >>> Thank you, >>> >>> Simone >>> -- >>> ______________________________________________________ >>> >>> Simone Giannerini Dipartimento di Scienze Statistiche >>> "Paolo Fortunati" Universita' di Bologna Via delle belle >>> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: >>> +39 051 232153 http://www2.stat.unibo.it/giannerini/ >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>
>>
-- Institute of Mathematics Ecole Polytechnique F?d?rale de
>> Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne >> Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907 >> >> >>
--
______________________________________________________ SG> Simone Giannerini Dipartimento di Scienze Statistiche SG> "Paolo Fortunati" Universita' di Bologna Via delle belle SG> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: SG> +39 051 232153 http://www2.stat.unibo.it/giannerini/ SG> ______________________________________________ SG> R-devel at r-project.org mailing list SG> https://stat.ethz.ch/mailman/listinfo/r-devel
--
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/ ______________________________________________________
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/
On 1/8/2009 9:29 AM, Simone Giannerini wrote:
Now I got how to reproduce it, it has nothing to do with multiple figure environment but rather with figure resizing. Here it is: curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) # Now expand the figure to full screen legend(-4,0.2,legend="curve",lty=1,col=4)
I think the only advice here is "don't do that". The problem is that the box is sized appropriately to surround the text when it is first drawn, then you scale everything up except the text, so the box becomes too big. The new box is appropriate to the text at the new size. Then you scale everything again when you save to a file, and the boxes end up different again. So the advice is: draw legends with the plot at its final size if you want the sizing to work properly. R doesn't save the fact that the size is supposed to be relative to the text, rather than relative to the plot region. Duncan Murdoch
Simone On Thu, Jan 8, 2009 at 2:39 PM, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
"SG" == Simone Giannerini <sgiannerini at gmail.com>
on Thu, 8 Jan 2009 14:08:17 +0100 writes:
SG> Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu SG> Ribatet <mathieu.ribatet at epfl.ch> wrote:
>> Dear Simone, >> >> Did mean that the legend (text and/or box) overlap with >> the Normal density?
SG> no, I mean that the two legend() commands, which are SG> identical in all but the y-coordinates, produce SG> different results, namely boxes with different widths. I don't see that behavior at all, rather the two boxes have identical dimensions for me. What does dev.cur() say? if anything with "X11..." (as you are on Linux), what does str(X11.options()) give? SG> Ciao SG> Simone
>> If so then I think there's no problem as the legend is >> placed where you told R to do. And R won't check (for >> you) if it will overlap or not with pre-existing >> graphical elements. >> >> On my computer, I got the expected results - if I >> understood correctly your issue though. For information: >> >> R version 2.8.1 (2008-12-22) Linux mathieu-laptop >> 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008 >> i686 GNU/Linux (Ubuntu Intrepid) >> >> Cheers, Mathieu >> >> Simone Giannerini a ?crit :
>>> >>> Dear all, >>> >>> there seems to be a problem with displayed legends when >>> a multiple figure environment is used, see the following >>> example: >>> >>> par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); >>> legend(-4,0.3,legend="curve",lty=1,col=4) >>> legend(-4,0.2,legend="curve",lty=1,col=4) >>> >>> >>> On my machines the first time the command legend() is >>> issued the legend box stretches over the >>> curve. Subsequent calls to legend seems to produce a >>> correct box instead. >>> >>> openSuse 11.0 >>> >>> platform x86_64-unknown-linux-gnu arch x86_64 os >>> linux-gnu system x86_64, linux-gnu status Patched major >>> 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 >>> language R version.string R version 2.8.1 Patched >>> (2009-01-07 r47501) >>> >>> I see this on the same version of R on Windows VISTA 32 >>> bit as well; I do not see this behaviour on a machine >>> with R 2.8.0. >>> >>> Thank you, >>> >>> Simone >>> -- >>> ______________________________________________________ >>> >>> Simone Giannerini Dipartimento di Scienze Statistiche >>> "Paolo Fortunati" Universita' di Bologna Via delle belle >>> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: >>> +39 051 232153 http://www2.stat.unibo.it/giannerini/ >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>
>>
-- Institute of Mathematics Ecole Polytechnique F?d?rale de
>> Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne >> Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907 >> >> >>
--
______________________________________________________ SG> Simone Giannerini Dipartimento di Scienze Statistiche SG> "Paolo Fortunati" Universita' di Bologna Via delle belle SG> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: SG> +39 051 232153 http://www2.stat.unibo.it/giannerini/ SG> ______________________________________________ SG> R-devel at r-project.org mailing list SG> https://stat.ethz.ch/mailman/listinfo/r-devel
--
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/ ______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
On Thu, 8 Jan 2009, Simone Giannerini wrote:
Now I got how to reproduce it, it has nothing to do with multiple figure environment but rather with figure resizing. Here it is: curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) # Now expand the figure to full screen legend(-4,0.2,legend="curve",lty=1,col=4)
When you resize graphics, text stays the same size (on most devices) and vector graphics does not. You can't expect the figure to be recomputed when you resize (and if you expect so, your expectations will be unfufilled). All that happens is that a low-level description is replayed. The windows() device does give you more options on resize.
Simone On Thu, Jan 8, 2009 at 2:39 PM, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
"SG" == Simone Giannerini <sgiannerini at gmail.com>
on Thu, 8 Jan 2009 14:08:17 +0100 writes:
SG> Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu SG> Ribatet <mathieu.ribatet at epfl.ch> wrote:
>> Dear Simone, >> >> Did mean that the legend (text and/or box) overlap with >> the Normal density?
SG> no, I mean that the two legend() commands, which are SG> identical in all but the y-coordinates, produce SG> different results, namely boxes with different widths. I don't see that behavior at all, rather the two boxes have identical dimensions for me. What does dev.cur() say? if anything with "X11..." (as you are on Linux), what does str(X11.options()) give? SG> Ciao SG> Simone
>> If so then I think there's no problem as the legend is >> placed where you told R to do. And R won't check (for >> you) if it will overlap or not with pre-existing >> graphical elements. >> >> On my computer, I got the expected results - if I >> understood correctly your issue though. For information: >> >> R version 2.8.1 (2008-12-22) Linux mathieu-laptop >> 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008 >> i686 GNU/Linux (Ubuntu Intrepid) >> >> Cheers, Mathieu >> >> Simone Giannerini a ?crit :
>>> >>> Dear all, >>> >>> there seems to be a problem with displayed legends when >>> a multiple figure environment is used, see the following >>> example: >>> >>> par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); >>> legend(-4,0.3,legend="curve",lty=1,col=4) >>> legend(-4,0.2,legend="curve",lty=1,col=4) >>> >>> >>> On my machines the first time the command legend() is >>> issued the legend box stretches over the >>> curve. Subsequent calls to legend seems to produce a >>> correct box instead. >>> >>> openSuse 11.0 >>> >>> platform x86_64-unknown-linux-gnu arch x86_64 os >>> linux-gnu system x86_64, linux-gnu status Patched major >>> 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 >>> language R version.string R version 2.8.1 Patched >>> (2009-01-07 r47501) >>> >>> I see this on the same version of R on Windows VISTA 32 >>> bit as well; I do not see this behaviour on a machine >>> with R 2.8.0. >>> >>> Thank you, >>> >>> Simone >>> -- >>> ______________________________________________________ >>> >>> Simone Giannerini Dipartimento di Scienze Statistiche >>> "Paolo Fortunati" Universita' di Bologna Via delle belle >>> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: >>> +39 051 232153 http://www2.stat.unibo.it/giannerini/ >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>
>>
-- Institute of Mathematics Ecole Polytechnique F?d?rale de
>> Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne >> Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907 >> >> >>
--
______________________________________________________ SG> Simone Giannerini Dipartimento di Scienze Statistiche SG> "Paolo Fortunati" Universita' di Bologna Via delle belle SG> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: SG> +39 051 232153 http://www2.stat.unibo.it/giannerini/ SG> ______________________________________________ SG> R-devel at r-project.org mailing list SG> https://stat.ethz.ch/mailman/listinfo/r-devel
--
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/ ______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thanks for your clarifications, I use legends only when the plot is at its final size and also had a look at windows() before posting but at first I could not relate the legends' behaviour to the resizing effect. Kind regards, Simone
On Thu, Jan 8, 2009 at 4:02 PM, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
On Thu, 8 Jan 2009, Simone Giannerini wrote:
Now I got how to reproduce it, it has nothing to do with multiple figure environment but rather with figure resizing. Here it is: curve(dnorm,col=4,from=-4,to=4); legend(-4,0.3,legend="curve",lty=1,col=4) # Now expand the figure to full screen legend(-4,0.2,legend="curve",lty=1,col=4)
When you resize graphics, text stays the same size (on most devices) and vector graphics does not. You can't expect the figure to be recomputed when you resize (and if you expect so, your expectations will be unfufilled). All that happens is that a low-level description is replayed. The windows() device does give you more options on resize.
Simone On Thu, Jan 8, 2009 at 2:39 PM, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
"SG" == Simone Giannerini <sgiannerini at gmail.com> on Thu, 8 Jan 2009 14:08:17 +0100 writes:
SG> Dear Mathieu, On Thu, Jan 8, 2009 at 12:14 PM, Mathieu SG> Ribatet <mathieu.ribatet at epfl.ch> wrote:
>> Dear Simone, >> >> Did mean that the legend (text and/or box) overlap with >> the Normal density?
SG> no, I mean that the two legend() commands, which are SG> identical in all but the y-coordinates, produce SG> different results, namely boxes with different widths. I don't see that behavior at all, rather the two boxes have identical dimensions for me. What does dev.cur() say? if anything with "X11..." (as you are on Linux), what does str(X11.options()) give? SG> Ciao SG> Simone
>> If so then I think there's no problem as the legend is >> placed where you told R to do. And R won't check (for >> you) if it will overlap or not with pre-existing >> graphical elements. >> >> On my computer, I got the expected results - if I >> understood correctly your issue though. For information: >> >> R version 2.8.1 (2008-12-22) Linux mathieu-laptop >> 2.6.27-11-generic #1 SMP Fri Dec 19 16:29:52 UTC 2008 >> i686 GNU/Linux (Ubuntu Intrepid) >> >> Cheers, Mathieu >> >> Simone Giannerini a ?crit :
>>> >>> Dear all, >>> >>> there seems to be a problem with displayed legends when >>> a multiple figure environment is used, see the following >>> example: >>> >>> par(mfrow=c(1,2)) curve(dnorm,col=4,from=-4,to=4); >>> legend(-4,0.3,legend="curve",lty=1,col=4) >>> legend(-4,0.2,legend="curve",lty=1,col=4) >>> >>> >>> On my machines the first time the command legend() is >>> issued the legend box stretches over the >>> curve. Subsequent calls to legend seems to produce a >>> correct box instead. >>> >>> openSuse 11.0 >>> >>> platform x86_64-unknown-linux-gnu arch x86_64 os >>> linux-gnu system x86_64, linux-gnu status Patched major >>> 2 minor 8.1 year 2009 month 01 day 07 svn rev 47501 >>> language R version.string R version 2.8.1 Patched >>> (2009-01-07 r47501) >>> >>> I see this on the same version of R on Windows VISTA 32 >>> bit as well; I do not see this behaviour on a machine >>> with R 2.8.0. >>> >>> Thank you, >>> >>> Simone >>> -- >>> ______________________________________________________ >>> >>> Simone Giannerini Dipartimento di Scienze Statistiche >>> "Paolo Fortunati" Universita' di Bologna Via delle belle >>> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: >>> +39 051 232153 http://www2.stat.unibo.it/giannerini/ >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>>
>>
-- Institute of Mathematics Ecole Polytechnique F?d?rale de
>> Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne >> Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907 >> >> >>
--
______________________________________________________ SG> Simone Giannerini Dipartimento di Scienze Statistiche SG> "Paolo Fortunati" Universita' di Bologna Via delle belle SG> arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: SG> +39 051 232153 http://www2.stat.unibo.it/giannerini/ SG> ______________________________________________ SG> R-devel at r-project.org mailing list SG> https://stat.ethz.ch/mailman/listinfo/r-devel
--
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/ ______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________________ Simone Giannerini Dipartimento di Scienze Statistiche "Paolo Fortunati" Universita' di Bologna Via delle belle arti 41 - 40126 Bologna, ITALY Tel: +39 051 2098262 Fax: +39 051 232153 http://www2.stat.unibo.it/giannerini/