2

I usually take the tikz-pgfplot route through gnuplot-lua interface to draw scientific figures for research papers. It usually works very good and I can seamlessly integrate my figures in latex documents. The figures thus produced is very high resolution and refined. However, the stumbling block is the high-resolution scatterplot of a large dataset - to tune of 100,000 points.

If I follow my usual tikz-pgfplot route, the latex file is produced but while compiling through pdflatex, one gets the tex memory exceeded... error. I also came to know that increasing tex's memory is not a good idea. So, I ended up producing an eps (encapsulated postscript) figure, which I then include in my latex document through tikz-pgfplot to render the annotations. It usually works but results a very large PDF file to the tune of 2 MB for a small figure and the PDF reader take long time to fully display figure.

I was wondering, if there any other ways to produce a high-resolution scatterplot of a large dataset? Any pointer would be highly appreciated.

Madhur

4

1 回答 1

6

10^5 点的任何矢量格式表示必然会很大,因为每个点都是单独描述的,即使它位于许多其他点的顶部或下方。通用的解决方案是对绘图使用位图格式,因为绘图中的每个像素要么设置要么不设置,无论其顶部有多少点。输出表示的大小是不依赖于点数的第一个近似值。

坚持使用 gnuplot,我可能会使用set terminal cairolatex png standalone生成初始绘图描述,然后使用 pdflatex 生成最终的 pdf,其中嵌入了位图。例如:

# create a bitmapped version
set term cairolatex png standalone size 10cm, 7cm
set output 'cairolatex+png.tex'
set xrange [0:1]
set sample 100000
plot '+' using (rand(0)):(rand(0)) with dots
unset output
system("pdflatex cairolatex+png")

# create a vector version
set term tikz standalone size 10cm, 7cm
set output 'tikz.tex'
set sample 10000
replot
unset output
system("pdflatex tikz")

第一个绘图立即完成并生成一个较小的文件。第二个图需要几分钟并生成一个更大的文件,尽管它只包含点数的 1/10。

[236] ls -s1 *.pdf
416 cairolatex+png.pdf
844 tikz.pdf

两者都使用乳胶作为绘图的文本部分,尽管默认字体可能不同。

于 2018-10-15T05:09:23.777 回答