Frank Schwach
2011-Mar-08 17:02 UTC
[R] positions and margins differ between X11 and SVG device
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.
Allan Engelhardt
2011-Mar-08 20:37 UTC
[R] positions and margins differ between X11 and SVG device
Looks the same on my machine, albeit using svg() instead of CairoSVG - what version are you using? One sometimes useful technique is to create the first graphics in a vector format (pdf, svg) and then use an editing program like Inkscape or Illustrator to do any touch-up before publication, as well as resizing and format conversion. Good luck! Allan On 08/03/11 17:02, Frank Schwach wrote:> 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 > > > >
Hi, I'm plotting a heatmap with values ranging from -10 to +10 and I would like the negative values to show up in shades of blue and the positive ones in shadea of red. Basically, I want exactly what the RColorBrewer palette RdBu does but with more of a gradual change (the RdBu can only give me 11 distinct colours). Any suggestions? Thanks! 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.