Graphics, Figures & TablesTikZ surface plot file size

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

TikZ surface plot file size

Post by h4mmk »

Hi, I am plotting three-dimensional surfaces using pgfplots. An example follows.
\documentclass{standalone}
\usepackage{pgfplots} 
\pgfplotsset{compat=1.14} 


\begin{document}
\begin{tikzpicture}
\begin{axis}[view={20}{10},axis lines=none,xmin=-15, xmax=15,ymin=-15, ymax=15,zmin=-1, zmax=4]

\addplot3[surf, 
           fill opacity=1, 
           draw opacity=1,
           shader=interp,
           colormap={outside}{color=(blue!40) color=(blue)},
           point meta=-abs(x),  
           mesh/interior colormap={inside}{color=(red!40) color=(red)},
           domain=0.01:15, 
           y domain=0:2*pi,
           samples=30 
           ]
           ({x*cos(deg(y))},{x*sin(deg(y))},{sqrt(x)});

\end{axis}
\end{tikzpicture}
\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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10337
Joined: Mon Mar 10, 2008 9:44 pm

TikZ surface plot file size

Post by Stefan Kottwitz »

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

Code: Select all

\pdfminorversion=5
\pdfcompresslevel=9
\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.

Stefan
LaTeX.org admin
h4mmk
Posts: 2
Joined: Thu Sep 07, 2017 3:58 pm

TikZ surface plot file size

Post by h4mmk »

Thanks very much for your helpful advice, which will certainly come in useful!

To get round the problem, I switched from TikZ to Asymptote. The latter seems better suited for displaying surfaces.
Post Reply