0

I'm making an EPS graphic of a scatterplot with a lot of points via R, with lots of data points.

setEPS()
postscript('figure.eps')
...
dev.off()

However, the eps file loads very slowly in evince. I have had similar problems for scatterplots in gnuplot. The eps file has 131,292 lines and is 3.6 megabytes. I recognize for an eps file this is fairly large, but there are a lot of points in the scatterplot.

I've read through the R options and I couldn't find a way to simplify it, is there a way I can alter this eps file so I can load it easily?

con
  • 5,767
  • 8
  • 33
  • 62
  • try `pch="."` and see if that helps ... – Ben Bolker Jan 06 '17 at 17:12
  • 1
    http://stackoverflow.com/questions/10945707/speed-up-plot-function-for-large-dataset/ – Ben Bolker Jan 06 '17 at 17:14
  • 1
    Use a bitmap instead of a vector image format, maybe. I guess each dot adds to the file size in the latter but not the former. – Frank Jan 06 '17 at 17:14
  • @BenBolker I've tried "pch = '.'" but that page looks like they're talking about _generating_ the plot, not _visualizing_ the plot. pch didn't change anything – con Jan 06 '17 at 17:22
  • Without seeing the EPS file its kinf of difficult to comment. You could try using Ghostscript directly instead of Evince. Since PostScript is a programming language its possible (but certainly not easy) to modify it and it may be possible to make it render faster. But frankly that is actually **not** an especially large file size,.nor by the sounds of it particularly complex. I'd suggest you post the file somewhere so we can look at it.(the EPS that is). – KenS Jan 08 '17 at 10:10

1 Answers1

0

The solution to making a scatterplot like this is called 'hexbin' the only problem is that you have to learn an entirely new plotting environment in R, which isn't so fun.

You can see the section 'High Density Scatterplots' here http://www.statmethods.net/graphs/scatterplot.html

I found the following R script to be very useful:

library(hexbin)
x <- read.delim('data.tsv', sep="\t")
bin <- hexbin(x[,1], x[,2], xbins = 500)
setEPS()
postscript('debug.eps')
plot(bin, legend=FALSE, colramp=BTY, xlab ='this will be the xlabel', ylab = 'this will be the ylabel\n\n', main= 'this is the title')
dev.off()

which comes very close to the original scatterplot which is too large to load.

con
  • 5,767
  • 8
  • 33
  • 62