LaTeX forum ⇒ Graphics, Figures & TablesTikZ surface plot file size

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 1
Joined: Thu Sep 07, 2017 3:58 pm

TikZ surface plot file size

Postby h4mmk » Thu Sep 07, 2017 4:09 pm

Hi, I am plotting three-dimensional surfaces using pgfplots. An example follows.

  1. \documentclass{standalone}
  2. \usepackage{pgfplots}
  3. \pgfplotsset{compat=1.14}
  6. \begin{document}
  7. \begin{tikzpicture}
  8. \begin{axis}[view={20}{10},axis lines=none,xmin=-15, xmax=15,ymin=-15, ymax=15,zmin=-1, zmax=4]
  10. \addplot3[surf,
  11. fill opacity=1,
  12. draw opacity=1,
  13. shader=interp,
  14. colormap={outside}{color=(blue!40) color=(blue)},
  15. point meta=-abs(x),
  16. mesh/interior colormap={inside}{color=(red!40) color=(red)},
  17. domain=0.01:15,
  18. y domain=0:2*pi,
  19. samples=30
  20. ]
  21. ({x*cos(deg(y))},{x*sin(deg(y))},{sqrt(x)});
  23. \end{axis}
  24. \end{tikzpicture}
  25. \end{document}

When I compile this code with PDFLaTeX, the resulting PDF document is 900KB. I have many such surfaces in the master file that I am working on, so it has a huge file size. I can reduce the size of each surface by reducing the number 30 in "samples=30", but quality suffers.

My question, then, is whether anyone has advice on how my code could be adjusted to drastically reduce the size of the files, but retain the quality. Too much to ask for, perhaps, but any suggestions on this subject will be appreciated nonetheless! Thank you very much.


User avatar
Stefan Kottwitz
Site Admin
Posts: 8606
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany

Postby Stefan Kottwitz » Wed Dec 20, 2017 8:12 pm

PDF compression could be used, such as, for example:

  1. \pdfminorversion=5
  2. \pdfcompresslevel=9
  3. \pdfobjcompresslevel=3

Either for the single plot and include it as pdf image, or for the whole document. Another option would be compression by Ghostscript.

Site admin

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests