[R] positions and margins differ between X11 and SVG device

Frank Schwach fs5 at sanger.ac.uk
Tue Mar 8 18:02:31 CET 2011


Hi,

I'm trying to get a plot ready for publication, which involves getting
it to look nice at a rather small size and to fine-tune positioning all
the labels and sizes of the margins.
I realise that I may not be doing this the right way and I welcome any
comments about better approaches to do this. What I have done so far is
open an X11 device with the size I want for the final output and I have
now managed to arrange all the elements as I wanted in the R script that
draws the plot.
Saving the plot to a bitmap format preserves all the positions and sizes
but the resulting quality is too low. Saving it to svg (also tried
CairoSVG) of course gives me excellent quality, but the positions and
margins are all completely different from the X11 window. Now I'm
wondering how others deal with this (surely common) situation?
Figuring out the positions while working blindly (saving to svg file all
the time and opening it again to see the result) surely can't be the way
to adjust the positions. But what else can I do if X11 output and svg
differ so much?

In fact, here is a toy example to demonstrate the differences:


x1=seq(0,2,by=0.01)
y1=2*sin(2*pi*(x1-1/4))

x11(width=1.67, height=2.28)
plot(x1,y1)

# looks completely different in svg (at least on my machine):

CairoSVG(file="test.svg", width=1.67, height=2.28)
plot(x1,y1)
dev.off()


Any help or general advice on formatting plots for publication would be
very welcome! 

Cheers,

Frank




-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE.



More information about the R-help mailing list