1

My goal is to plot 3D data (x,y,z coordinates) such that a certain path on/inside a unit ball is illustrated. Since the path will not only be on the surface of the unit ball I have to encode the norm of $(x,y,z)$ as color. Plotting the path alone works quite well using pgfplots. The output file format should be eps/pdf (preferably eps). Here is a link to pastebin, where I have put some example data (example.dat).

Currently I am using the code

\documentclass{article}
\usepackage{pgfplots}
\usepackage{fullpage}

\pgfplotsset{compat=1.10}
\tikzset{mark size=.5}

\usetikzlibrary{arrows,shapes.misc,shapes.arrows,chains,matrix,positioning,scopes,decorations.pathmorphing,shadows,patterns,}

\pagestyle{empty}

\begin{document}

\begin{tikzpicture} 
    \begin{axis}[
      axis lines=center,
      ticks=none,
      xmin=-1,xmax=1,
      ymin=-1,ymax=1,
      zmin=-1,zmax=1
      ]
      \addplot3[scatter,scatter src=explicit] file {example.dat};
    \end{axis}
\end{tikzpicture}
\end{document}

which shows the colored data as I want (neglecting labels). I am not able to include a sphere for better visualization. The sphere+path should look somewhat like this(except labels/nodes).

The sphere should preferably look like in the link above (shaded) but something like in this answer would also be okay with fewer grid lines (like 3-4). I tried to add the plot from the answer but I do not get the opacity at all, even if I compile only the answer code itself.

I compile my figures using the following bash script

#!/bin/bash
# Give name of .tex file as argument to the command prompt (./compileFigure name_of_tex)

latex $1.tex
dvips -E $1.dvi -o temp.eps
epstool --copy --bbox temp.eps $1.eps
rm *.aux *.log *.dvi temp.eps

What am I missing here to achieve the desired output?

Lukas
  • 133
  • Welcome at tex.sx! The missing opacity support might be related to the driver, i.e. to epstool. Have you tried to omit epstool? Does the problem appear with pdflatex as well? – Christian Feuersänger Aug 07 '15 at 22:00
  • @ChristianFeuersänger Yes, it does also happen if I just use pdflatex myfile.tex. Sorry, forgot to mention that in my question – Lukas Aug 08 '15 at 11:57
  • Can you list the package versions on your system? I have no problems with opacity. If a package upgrade would solve the problem, that would be fine. – Christian Feuersänger Aug 08 '15 at 21:47
  • @ChristianFeuersänger Thanks! Updating pgfplots package helped together with using pdflatex. I will put the working code as an answer – Lukas Aug 09 '15 at 08:48
  • 4
    I'm voting to close this question as off-topic because it is a no-repro after a package update. – percusse Aug 09 '15 at 13:43

1 Answers1

0

After updating packages opacity now works fine and I am able to comile the following MWE with pdflatex to achieve an output like I was looking for.

\documentclass{article}
\usepackage{pgfplots}
\usepackage{fullpage}

\pgfplotsset{compat=1.10}
\tikzset{mark size=.5}
\pagestyle{empty}

\begin{document}
\begin{tikzpicture} 
    \begin{axis}[
        axis lines=center,
        axis equal image,
        ticks=none,
        xmin=-1,xmax=1,
        ymin=-1,ymax=1,
        zmin=-1,zmax=1,
        colormap/blackwhite
        ]
    \addplot3[%
        opacity = 0.2,
        surf,
        z buffer = sort,
        samples = 21,
        variable = \u,
        variable y = \v,
        domain = 0:180,
        y domain = 0:360,
    ]
    ({cos(u)*sin(v)}, {sin(u)*sin(v)}, {cos(v)});
    \end{axis}
    \begin{axis}[
        axis lines=center,
        axis equal image,
        ticks=none,
        xmin=-1,xmax=1,
        ymin=-1,ymax=1,
        zmin=-1,zmax=1
        ]
    \addplot3[scatter,scatter src=explicit] file {example.dat};
    \end{axis}
\end{tikzpicture}
\end{document}

Of course, some finetuning is needed. But in principle this is what I was looking for.

Lukas
  • 133