[R] postscript printer breaking up long strings

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Apr 30 22:40:02 CEST 2009


On 30-Apr-09 18:50:38, tommers wrote:
> For a long string in an axis title, or main title the postscript device
> breaks apart the long strings into smaller strings.  For example,
> 
  postscript('linebreaktest.eps')
  plot(1,xlab='aReallyLongStringToSeeHowItBreaks',
         ylab='aReallyLongStringToSeeHowItBreaks')
  for(i in
c(.6,1,1.4))text(i,i,'aReallyLongStringToSeeHowItBreaks')
  dev.off()
> 
> produces the attached output.
> http://www.nabble.com/file/p23322197/linebreaktest.eps
> linebreaktest.eps 

In the graph shown in your URL above, the xlab and the ylab
appear in their entirety, unbroken. So does the one plotted
in the middle of the graph. I get the same when I run your code.

The texts you plotted at the first and third of the positions
(i,i) also are not (I think) unbroken -- they are simply not
entirely visible.

The one at bottom left is missing its start "aReallyLongSt",
and the one at top right is missing its end "eHowItBreaks".

These apparent truncations arise because the beginning of the
first, and the end of the second, are outside the plotting
area, and so when the postcript() driver puts a BoundingBox
at the border of the potting area this has the effect of
"clipping" these strings when they are displayed.

The apparently "broken" strings in the PostScript code you
quote below are perfectly normal in PostScript. When dealing
with text in a variable-width font, a PS driver will typically
split continuous text into chunks, to allow for effects like
kerning (or other adjustments of spacing) between the chunks.
You will note that all five instances of the string are split
in the same places, despite the fact that at least three of
them come out perfectly (according to the graph on your URL).

So nothing is wrong. You will have to adjust the extent of
your plotting area, or adjust the "pos" or "just" of your
(i,i) labels, to be able to see them in their entirety.

Hoping this helps,
Ted.

> The most important lines from the eps source are at the end
> of the file:
> ********************************************
> 309.70 36.72 (aReallyLongStr) 0 ta
> 0.180 (ingT) tb
> -1.440 (oSeeHo) tb
> -0.180 (wItBreaks) tb gr
> 30.96 212.50 (aReallyLongStr) 90 ta
> 0.180 (ingT) tb
> -1.440 (oSeeHo) tb
> -0.180 (wItBreaks) tb gr
> 77.04 91.44 743.76 534.96 cl
> /Font1 findfont 12 s
> 0 setgray
> 1.03 104.76 (aReallyLongStr) 0 ta
> 0.180 (ingT) tb
> -1.440 (oSeeHo) tb
> -0.180 (wItBreaks) tb gr
> 309.70 310.10 (aReallyLongStr) 0 ta
> 0.180 (ingT) tb
> -1.440 (oSeeHo) tb
> -0.180 (wItBreaks) tb gr
> 618.36 515.43 (aReallyLongStr) 0 ta
> 0.180 (ingT) tb
> -1.440 (oSeeHo) tb
> -0.180 (wItBreaks) tb gr
> *******************************************************
> Each string is broken into 4 chunks.  Has anyone else had this problem?
> 
> Thanks!
> -- 

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 30-Apr-09                                       Time: 21:39:59
------------------------------ XFMail ------------------------------




More information about the R-help mailing list