[Tex/LaTex] Dashed axis lines

pgfplots

How can make the axis lines that go from the origin to each of the coordinates dashed? For instance I want the axis line that goes from (0,0,0) to (0,0,1) to be dashed.

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}[scale=1]
  \begin{axis}[view={40}{20}, ticks = none, axis on top, axis lines=center, y
    dir=reverse, ymin=0, ymax=2, xmin=0, xmax=2, zmin=0, zmax=2,
    xlabel=$p_{1}$, ylabel=$p_{2}$, zlabel=$p_{3}$, every axis y label/.append
    style={at=(ticklabel* cs:0)}]

  \addplot3[thick,mark=*] coordinates {(1,0,0) (0,1,0) (0,0,1)} --cycle;
  \node [above right] at (axis cs:1,0,0) {$(1,0,0)$};
  \node [above left] at (axis cs:0,1,0) {$(0,1,0)$};
  \node [above right] at (axis cs:0,0,1) {$(0,0,1)$};
  \end{axis}
\end{tikzpicture}
\end{document}

Best Answer

Perhaps my approach is too simplistic- draw a dashed white line on top of the axis for the relevant parts using

\draw[dashed,white] (axis cs: 0,0,0)--(axis cs: 0,0,1);
\draw[dashed,white] (axis cs: 0,0,0)--(axis cs: 0,1,0);
\draw[dashed,white] (axis cs: 0,0,0)--(axis cs: 1,0,0);

You need to comment out axis on top, for this to work.

screenshot

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}[scale=1]
    \begin{axis}[
            view={40}{20}, 
            ticks = none, 
            %axis on top, 
            axis lines=center, y
            dir=reverse, 
            ymin=0, ymax=2, xmin=0, xmax=2, zmin=0, zmax=2,
            xlabel=$p_{1}$, ylabel=$p_{2}$, zlabel=$p_{3}$, 
            every axis y label/.append style={at=(ticklabel* cs:0)},
        ]
        \addplot3[thick,mark=*] coordinates {(1,0,0) (0,1,0) (0,0,1)} --cycle;
        \node [above right] at (axis cs:1,0,0) {$(1,0,0)$};
        \node [above left] at (axis cs:0,1,0) {$(0,1,0)$};
        \node [above right] at (axis cs:0,0,1) {$(0,0,1)$};
        \draw[dashed,white] (axis cs: 0,0,0)--(axis cs: 0,0,1);
        \draw[dashed,white] (axis cs: 0,0,0)--(axis cs: 0,1,0);
        \draw[dashed,white] (axis cs: 0,0,0)--(axis cs: 1,0,0);
    \end{axis}
\end{tikzpicture}
\end{document}

If you look closely, you'll see that the axis are still present. This might be a good or a bad thing.... If you don't want to see them at all, add thick to the draw commands:

        \draw[dashed,white,thick] (axis cs: 0,0,0)--(axis cs: 1,0,0);
Related Question