[R] Legend text -- discrepancy between X11 and postscript

Itay Furman itayf at fhcrc.org
Thu Jan 15 08:08:44 CET 2004


Hi,

When I place a legend on a plot it looks exactly as I intended
on the screen. However, almost always, when I export this to 
postscript file, the legend's text protrudes through the legend's 
frame (the latter being placed correctly).
See the appended example code. I can send the EPS file as well 
for those that are interested (<4 kb; <200 lines).

I found nothing in the FAQS, or in R-intro to enlighten me. I 
tried few things --- changing font size, setting legend's text 
width, etc. --- but eventually gave up.

How can I get a consistent X11 and PS rendering?

(R 1.8.1 on Linux RedHat 9; GhostView 3.5.8)

	TIA
	Itay

####  Example for X11-EPS discrepancy in legend rendering  ####

## A useless data to plot
x    <- 0:10;         XY <- list(x=x, y=2*x)

## Set lims explicitly; use later in placing the legend.
xlim <- range(XY$x);  ylim <- range(XY$y)                     

plot(XY, xlim=xlim, ylim=ylim, type="l", lty=1, col=2, axes=FALSE)
axis(1); axis(2)

## Legend and plot share the bottom-right corner.
legend(xlim[2], ylim[1], "A set of random numbers",
       lty=1, col=2, xjust=1, yjust=0)

## On the screen: OK. Now produce EPS file.
dev.copy2eps(file="test.eps", paper="letter")
#########################   End example   ##################

--
itayf at fhcrc.org




More information about the R-help mailing list