[Rd] [FORGED] Height not set properly in grDevices::jpeg() with type = "cairo"
Paul Murrell
paul at stat.auckland.ac.nz
Tue Feb 27 04:01:06 CET 2018
Hi
That fix checks out for me so I have committed the change to r-devel.
Thanks for the report!
Paul
On 28/11/17 16:25, Marius wrote:
> Hi,
> I have been having issues producing plots in JPEG format, using type =
> "cairo" to get better anti-aliasing. When trying to set the physical
> size with units = "cm" or units = "mm", the width is set correctly but
> the height is not - it looks like the height is simply treated as
> pixels regardless of the 'units' argument.
>
> Example:
>
>
> x = 1:10
> y = 2 * x
> jpeg("ExamplePlot.jpg",
> type = "cairo",
> width = 200,
> height = 200,
> units = "mm",
> res = 96)
> plot(x, y)
> dev.off()
>
>
> On my system (Windows 7, running R 3.4.2), this produces a plot that
> is 755 x 200 pixels, and is vertically very squashed.
>
> Looking at grDevices::jpeg, it looks like the culprit is these lines:
>
> g <- .geometry(width, height, units, res)
> if (match.arg(type) == "cairo") {
> antialias <- match(match.arg(antialias), aa.cairo)
> invisible(.External(C_devCairo, filename, 3L, g$width,
> height, pointsize, bg, res, antialias, quality, if
> (nzchar(family)) family else "sans",
> 300))
> }
>
> g$width is used, but "height" is used instead of "g$height". I suspect
> simply using "g$height" here would fix the issue but have not had time
> to test this.
>
> My R.version:
>
> platform x86_64-w64-mingw32
> arch x86_64
> os mingw32
> system x86_64, mingw32
> status
> major 3
> minor 4.2
> year 2017
> month 09
> day 28
> svn rev 73368
> language R
> version.string R version 3.4.2 (2017-09-28)
> nickname Short Summer
>
> Please let me know if any further information is needed.
>
> Thanks,
> Marius
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-devel
mailing list