Re: [R] CairoPDF and greek letter spacing

2012-01-18 Thread James Cloos
> "RT" == Rolf Turner  writes:

RT> Compare:

RT> require(lattice)
RT> cairo_pdf(file="mung.pdf")
RT> 
print(xyplot(y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))
RT> dev.off()
RT> and
RT> pdf(file="gorp.pdf")
RT> 
print(xyplot(y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))
RT> dev.off()

After using qpdf(1) to uncompress the pdfs, the latter produces:

BT
/F6 1 Tf 14.00 0.00 -0.00 14.00 270.63 487.95 Tm (m) Tj
ET
BT
/F2 1 Tf 14.00 0.00 -0.00 14.00 278.69 487.95 Tm (m) Tj
ET

where /F6 is /Symbol and /F2 is /Helvetica.

The former produces:

14.399414 0 0 14.399414 209.167969 487.277344 Tm
% (Length =) elided
/f-2-0 1 Tf
0.786979 -0.00461173 Td
Tj
/f-0-0 1 Tf
0.625025 -0.0124788 Td
(m)Tj

where /f-2-0 is /DQHRIK+Symbol and f-0-0 is /OJZLOW+NimbusSanL-Regu.

In gorp, (m)’s start point is 8.06 units right of (μ)’s start point.

In mung, (m)’s start point is 0.161954 units right of (μ)’s end point.

The version of /DQHRIK+Symbol has a /mu with a width of 576 font units
and a 1000 unit em.  At 14.4pt that is a width of 8.294 pdf points.

Gorp does not have embedded fonts, but Adobe’s AFM file for /Symbol
also specified 576 font units for /mu’s width.  That line of text,
though is set at 14pt rather than 14.4pt, so a width of 8.064 pts.

It looks like all of the text in gorp is set tighter than in mung.

Perhaps using utf8 would look better:

  require(lattice)
  cairo_pdf(file="mung8.pdf", family="serif")
  print(xyplot(y~x,data=data.frame(x=1:10,y=1:10),main="Length = µm"))
  dev.off()

It certainly looks better here, with sans, serif or any font which has
latin and greek glyphs.  To do that with Latin Modern Roman, though, I
had to use U+00B5 MICRO SIGN (µ) rather than U+03BC GREEK SMALL LETTER MU.
(The snippet above uses MICRO SIGN.)

I think the takeaway is that cairo works better with a utf8 workflow.

-JimC
-- 
James Cloos  OpenPGP: 1024D/ED7DAEA6

__
R-help@r-project.org 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.


Re: [R] CairoPDF and greek letter spacing

2012-01-11 Thread Chris Campbell
As a workaround you could use escape characters, then adjust the font style as 
necessary.

cairo_pdf(file = "zend.pdf")
print(xyplot(y ~ x, 
  data = data.frame(x = 1:10, y = 1:10),
  main = "Length (\u03BCm)"))
dev.off()

Regards

Chris Campbell
MANGO SOLUTIONS
Data Analysis that Delivers
+44 1249 767700

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Walker, John Stephen
Sent: 11 January 2012 16:01
To: David Winsemius; Rolf Turner
Cc: r-help@r-project.org
Subject: Re: [R] CairoPDF and greek letter spacing

Thanks for the input, but I can confirm the either form of the paste command 
i.e. expression(paste("Length (", mu*m, ")")) or my original which had 
expression(paste("Length (", mu, "m)")), and the expression command alone have 
the same effect. It may be limited to Linux machines 
(which I did state I used  in my first post) as when I previously used an OS X 
machine I didn't see the bug.   I don't use OS X anymore, I've implemented a 
completely Linux based 
lab and would like to get this sorted out. Any suggestions? Rolf, if you can 
repoduce it then I think we have a bug report but to whom? R or Cairo?

John




From: David Winsemius [dwinsem...@comcast.net]
Sent: Monday, January 09, 2012 10:36 PM
To: Rolf Turner
Cc: Walker, John Stephen; r-help@r-project.org
Subject: Re: [R] CairoPDF and greek letter spacing

On Jan 10, 2012, at 12:22 AM, Rolf Turner wrote:

> On 10/01/12 15:25, David Winsemius wrote:
>>
>> On Jan 9, 2012, at 8:19 PM, Rolf Turner wrote:
>>
>>> On 10/01/12 11:40, John Walker wrote:
>>>> I have a small problem with R graphics output. When I use the 
>>>> lattice package and CairoPDF to generate publication quality graphs 
>>>> I often use the expression to create an axis title that has 
>>>> microlitres or micrometers as a unit. I use something like the 
>>>> following 'expression(paste("Length (", mu,"m )"))' as an argument 
>>>> to the xlabel function. The command works but the mu and 'm' have a 
>>>> space between them. It looks like 'u m' rather than 'um'. It only 
>>>> seems to happen with the CairoPDF output on my linux machine, it's 
>>>> fine on the X11 device.
>>>> I've fixed it in the past by importing the pdf into inkscape and 
>>>> manually adjusting the spacing (it's more difficult than it sounds 
>>>> because I can't actually adjust the spacing but have to delete the 
>>>> mu and re-enter it).  Is there something I'm doing wrong? Is this a 
>>>> known bug?  How can I fix it?
>>> I can't help, but I can confirm the problem, for what *that* is 
>>> worth.
>>>
>>> It seems be an unfortunate interaction between lattice graphics and 
>>> the cairo_pdf() device.
>>>
>>> The space between the "mu" and the "m" does not appear with 
>>> ``ordinary'' R graphics, irrespective of device, nor does it appear 
>>> with lattice graphics and, e.g. the pdf() device.  But it does 
>>> appear with lattice graphics *and* the cairo_pdf() device.
>>>
>>> That probably means that the problem is subtle and will be difficult 
>>> to impossible to fix. :-(
>>
>> Doubtful. Do either of you realize that `paste` is a plotmath 
>> function that is misused more often than correctly used (at least as 
>> judged by the number o errors submitted to r-help)? I see no workable 
>> example, but if I did I would be trying instead :
>>
>> expression(Length~mu*m)
>
> You meant expression(Length==mu*m).

I thought what was wanted:

main=expression(Length~group("(",mu*m,")")) # Or

main=expression(Length~"("*mu*m*")")


And on a Mac (Leopard, R 2.14.1 Patched)  I could not get a different display 
on the screen device and either pdf or cairo_pdf so your experience may have 
something to do with the as yet unstated OSes.


>  And yes that helps a bit, but there's still a bit more space between 
> the mu and the m than one would like.
>
> Compare:
>
>require(lattice)
>cairo_pdf(file="mung.pdf")
>
> print
> (xyplot
> (y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))
>dev.off()
> and
>pdf(file="gorp.pdf")
>
> print
> (xyplot
> (y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))
>dev.off()
>
> There's not much in it, but there's just enough to be annoying.
>
>c

Re: [R] CairoPDF and greek letter spacing

2012-01-11 Thread Walker, John Stephen
Thanks for the input, but I can confirm the either form of the paste command 
i.e. expression(paste("Length (", mu*m, ")")) or my original which had 
expression(paste("Length (", mu, "m)")), and the expression command alone have 
the same effect. It may be limited to Linux machines 
(which I did state I used  in my first post) as when I previously used an OS X 
machine I didn't see the bug.   I don't use OS X anymore, I've implemented a 
completely Linux based 
lab and would like to get this sorted out. Any suggestions? Rolf, if you can 
repoduce it then I think we have a bug report but to whom? R or Cairo?

John




From: David Winsemius [dwinsem...@comcast.net]
Sent: Monday, January 09, 2012 10:36 PM
To: Rolf Turner
Cc: Walker, John Stephen; r-help@r-project.org
Subject: Re: [R] CairoPDF and greek letter spacing

On Jan 10, 2012, at 12:22 AM, Rolf Turner wrote:

> On 10/01/12 15:25, David Winsemius wrote:
>>
>> On Jan 9, 2012, at 8:19 PM, Rolf Turner wrote:
>>
>>> On 10/01/12 11:40, John Walker wrote:
>>>> I have a small problem with R graphics output. When I use the
>>>> lattice
>>>> package and CairoPDF to generate publication quality graphs I
>>>> often use
>>>> the expression to create an axis title that has microlitres or
>>>> micrometers as a unit. I use something like the following
>>>> 'expression(paste("Length (", mu,"m )"))' as an argument to the
>>>> xlabel
>>>> function. The command works but the mu and 'm' have a space between
>>>> them. It looks like 'u m' rather than 'um'. It only seems to
>>>> happen with
>>>> the CairoPDF output on my linux machine, it's fine on the X11
>>>> device.
>>>> I've fixed it in the past by importing the pdf into inkscape and
>>>> manually adjusting the spacing (it's more difficult than it sounds
>>>> because I can't actually adjust the spacing but have to delete
>>>> the mu
>>>> and re-enter it).  Is there something I'm doing wrong? Is this a
>>>> known
>>>> bug?  How can I fix it?
>>> I can't help, but I can confirm the problem, for what *that* is
>>> worth.
>>>
>>> It seems be an unfortunate interaction between lattice graphics and
>>> the cairo_pdf() device.
>>>
>>> The space between the "mu" and the "m" does not appear with
>>> ``ordinary'' R graphics, irrespective of device, nor does it appear
>>> with lattice graphics and, e.g. the pdf() device.  But it does
>>> appear
>>> with lattice graphics *and* the cairo_pdf() device.
>>>
>>> That probably means that the problem is subtle and will be difficult
>>> to impossible to fix. :-(
>>
>> Doubtful. Do either of you realize that `paste` is a plotmath
>> function that is misused more often than correctly used (at least
>> as judged by the number o errors submitted to r-help)? I see no
>> workable example, but if I did I would be trying instead :
>>
>> expression(Length~mu*m)
>
> You meant expression(Length==mu*m).

I thought what was wanted:

main=expression(Length~group("(",mu*m,")")) # Or

main=expression(Length~"("*mu*m*")")


And on a Mac (Leopard, R 2.14.1 Patched)  I could not get a different
display on the screen device and either pdf or cairo_pdf so your
experience may have something to do with the as yet unstated OSes.


>  And yes that helps a bit, but there's
> still a bit more space between the mu and the m than one would like.
>
> Compare:
>
>require(lattice)
>cairo_pdf(file="mung.pdf")
>
> print
> (xyplot
> (y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))
>dev.off()
> and
>pdf(file="gorp.pdf")
>
> print
> (xyplot
> (y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))
>dev.off()
>
> There's not much in it, but there's just enough to be annoying.
>
>cheers,
>
>Rolf
>
> P. S.  And I have never been able to figure out *anything* about how
> paste() and
> expression() interact.  It is a complete mystery, and a matter of
> trying things more
> or less at random until something more or less works.
>
>R. T.
>
> P^2. S.  I just realised that there's more space between the letters
> of "Length" in
> the cairo_pdf version, as well.  Which is, I guess, The
> Explanation.  Is it a font thing?
>
>R. T.

David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org 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.


Re: [R] CairoPDF and greek letter spacing

2012-01-09 Thread David Winsemius


On Jan 10, 2012, at 12:22 AM, Rolf Turner wrote:


On 10/01/12 15:25, David Winsemius wrote:


On Jan 9, 2012, at 8:19 PM, Rolf Turner wrote:


On 10/01/12 11:40, John Walker wrote:
I have a small problem with R graphics output. When I use the  
lattice
package and CairoPDF to generate publication quality graphs I  
often use

the expression to create an axis title that has microlitres or
micrometers as a unit. I use something like the following
'expression(paste("Length (", mu,"m )"))' as an argument to the  
xlabel

function. The command works but the mu and 'm' have a space between
them. It looks like 'u m' rather than 'um'. It only seems to  
happen with
the CairoPDF output on my linux machine, it's fine on the X11  
device.

I've fixed it in the past by importing the pdf into inkscape and
manually adjusting the spacing (it's more difficult than it sounds
because I can't actually adjust the spacing but have to delete  
the mu
and re-enter it).  Is there something I'm doing wrong? Is this a  
known

bug?  How can I fix it?
I can't help, but I can confirm the problem, for what *that* is  
worth.


It seems be an unfortunate interaction between lattice graphics and
the cairo_pdf() device.

The space between the "mu" and the "m" does not appear with
``ordinary'' R graphics, irrespective of device, nor does it appear
with lattice graphics and, e.g. the pdf() device.  But it does  
appear

with lattice graphics *and* the cairo_pdf() device.

That probably means that the problem is subtle and will be difficult
to impossible to fix. :-(


Doubtful. Do either of you realize that `paste` is a plotmath  
function that is misused more often than correctly used (at least  
as judged by the number o errors submitted to r-help)? I see no  
workable example, but if I did I would be trying instead :


expression(Length~mu*m)


You meant expression(Length==mu*m).


I thought what was wanted:

main=expression(Length~group("(",mu*m,")")) # Or

main=expression(Length~"("*mu*m*")")


And on a Mac (Leopard, R 2.14.1 Patched)  I could not get a different  
display on the screen device and either pdf or cairo_pdf so your  
experience may have something to do with the as yet unstated OSes.




 And yes that helps a bit, but there's
still a bit more space between the mu and the m than one would like.

Compare:

   require(lattice)
   cairo_pdf(file="mung.pdf")

print 
(xyplot 
(y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))

   dev.off()
and
   pdf(file="gorp.pdf")

print 
(xyplot 
(y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))

   dev.off()

There's not much in it, but there's just enough to be annoying.

   cheers,

   Rolf

P. S.  And I have never been able to figure out *anything* about how  
paste() and
expression() interact.  It is a complete mystery, and a matter of  
trying things more

or less at random until something more or less works.

   R. T.

P^2. S.  I just realised that there's more space between the letters  
of "Length" in
the cairo_pdf version, as well.  Which is, I guess, The  
Explanation.  Is it a font thing?


   R. T.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org 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.


Re: [R] CairoPDF and greek letter spacing

2012-01-09 Thread Rolf Turner

On 10/01/12 15:25, David Winsemius wrote:


On Jan 9, 2012, at 8:19 PM, Rolf Turner wrote:


On 10/01/12 11:40, John Walker wrote:

I have a small problem with R graphics output. When I use the lattice
package and CairoPDF to generate publication quality graphs I often use
the expression to create an axis title that has microlitres or
micrometers as a unit. I use something like the following
'expression(paste("Length (", mu,"m )"))' as an argument to the xlabel
function. The command works but the mu and 'm' have a space between
them. It looks like 'u m' rather than 'um'. It only seems to happen 
with

the CairoPDF output on my linux machine, it's fine on the X11 device.
I've fixed it in the past by importing the pdf into inkscape and
manually adjusting the spacing (it's more difficult than it sounds
because I can't actually adjust the spacing but have to delete the mu
and re-enter it).  Is there something I'm doing wrong? Is this a known
bug?  How can I fix it?

I can't help, but I can confirm the problem, for what *that* is worth.

It seems be an unfortunate interaction between lattice graphics and
the cairo_pdf() device.

The space between the "mu" and the "m" does not appear with
``ordinary'' R graphics, irrespective of device, nor does it appear
with lattice graphics and, e.g. the pdf() device.  But it does appear
with lattice graphics *and* the cairo_pdf() device.

That probably means that the problem is subtle and will be difficult
to impossible to fix. :-(


Doubtful. Do either of you realize that `paste` is a plotmath function 
that is misused more often than correctly used (at least as judged by 
the number o errors submitted to r-help)? I see no workable example, 
but if I did I would be trying instead :


expression(Length~mu*m)


You meant expression(Length==mu*m).  And yes that helps a bit, but there's
still a bit more space between the mu and the m than one would like.

Compare:

require(lattice)
cairo_pdf(file="mung.pdf")

print(xyplot(y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))

dev.off()
and
pdf(file="gorp.pdf")

print(xyplot(y~x,data=data.frame(x=1:10,y=1:10),main=expression(Length==mu*m)))

dev.off()

There's not much in it, but there's just enough to be annoying.

cheers,

Rolf

P. S.  And I have never been able to figure out *anything* about how 
paste() and
expression() interact.  It is a complete mystery, and a matter of trying 
things more

or less at random until something more or less works.

R. T.

P^2. S.  I just realised that there's more space between the letters of 
"Length" in
the cairo_pdf version, as well.  Which is, I guess, The Explanation.  Is 
it a font thing?


R. T.

__
R-help@r-project.org 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.


Re: [R] CairoPDF and greek letter spacing

2012-01-09 Thread David Winsemius


On Jan 9, 2012, at 8:19 PM, Rolf Turner wrote:


On 10/01/12 11:40, John Walker wrote:

I have a small problem with R graphics output. When I use the lattice
package and CairoPDF to generate publication quality graphs I often  
use

the expression to create an axis title that has microlitres or
micrometers as a unit. I use something like the following
'expression(paste("Length (", mu,"m )"))' as an argument to the  
xlabel

function. The command works but the mu and 'm' have a space between
them. It looks like 'u m' rather than 'um'. It only seems to happen  
with

the CairoPDF output on my linux machine, it's fine on the X11 device.
I've fixed it in the past by importing the pdf into inkscape and
manually adjusting the spacing (it's more difficult than it sounds
because I can't actually adjust the spacing but have to delete the mu
and re-enter it).  Is there something I'm doing wrong? Is this a  
known

bug?  How can I fix it?

I can't help, but I can confirm the problem, for what *that* is worth.

It seems be an unfortunate interaction between lattice graphics and
the cairo_pdf() device.

The space between the "mu" and the "m" does not appear with
``ordinary'' R graphics, irrespective of device, nor does it appear
with lattice graphics and, e.g. the pdf() device.  But it does appear
with lattice graphics *and* the cairo_pdf() device.

That probably means that the problem is subtle and will be difficult
to impossible to fix. :-(


Doubtful. Do either of you realize that `paste` is a plotmath function  
that is misused more often than correctly used (at least as judged by  
the number o errors submitted to r-help)? I see no workable example,  
but if I did I would be trying instead :


expression(Length~mu*m)

--
David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org 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.


Re: [R] CairoPDF and greek letter spacing

2012-01-09 Thread Rolf Turner

On 10/01/12 11:40, John Walker wrote:

I have a small problem with R graphics output. When I use the lattice
package and CairoPDF to generate publication quality graphs I often use
the expression to create an axis title that has microlitres or
micrometers as a unit. I use something like the following
'expression(paste("Length (", mu,"m )"))' as an argument to the xlabel
function. The command works but the mu and 'm' have a space between
them. It looks like 'u m' rather than 'um'. It only seems to happen with
the CairoPDF output on my linux machine, it's fine on the X11 device.
I've fixed it in the past by importing the pdf into inkscape and
manually adjusting the spacing (it's more difficult than it sounds
because I can't actually adjust the spacing but have to delete the mu
and re-enter it).  Is there something I'm doing wrong? Is this a known
bug?  How can I fix it?

I can't help, but I can confirm the problem, for what *that* is worth.

It seems be an unfortunate interaction between lattice graphics and
the cairo_pdf() device.

The space between the "mu" and the "m" does not appear with
``ordinary'' R graphics, irrespective of device, nor does it appear
with lattice graphics and, e.g. the pdf() device.  But it does appear
with lattice graphics *and* the cairo_pdf() device.

That probably means that the problem is subtle and will be difficult
to impossible to fix. :-(

Good luck.

cheers,

Rolf Turner

__
R-help@r-project.org 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.


[R] CairoPDF and greek letter spacing

2012-01-09 Thread John Walker
I have a small problem with R graphics output. When I use the lattice
package and CairoPDF to generate publication quality graphs I often use
the expression to create an axis title that has microlitres or
micrometers as a unit. I use something like the following
'expression(paste("Length (", mu,"m )"))' as an argument to the xlabel
function. The command works but the mu and 'm' have a space between
them. It looks like 'u m' rather than 'um'. It only seems to happen with
the CairoPDF output on my linux machine, it's fine on the X11 device.
I've fixed it in the past by importing the pdf into inkscape and
manually adjusting the spacing (it's more difficult than it sounds
because I can't actually adjust the spacing but have to delete the mu
and re-enter it).  Is there something I'm doing wrong? Is this a known
bug?  How can I fix it?

-- 
John Walker
Assistant Professor of Cardiology
Department of Medicine
University of Colorado Health Sciences Center
RC2 Room 8412
12700 East 19th Ave B139
Aurora, CO 80045
Office: 303 724 4545

__
R-help@r-project.org 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.