5

I am plotting patches and do not want them to be colored according to their z-values. Instead, I want to define the colors by myself.

Here is an example:

\addplot3[area legend,patch,forget plot,patch type=triangle,color=red,opacity=0.8]
table[row sep=crcr, point meta=\thisrow{c}] {%
x   y   z   c\\
0   0   0   0\\
0   0.3 0   0\\
0.3 0   0   0\\
};

I can override the color with color=red, but the edge color of the patches is still plotted in different Colors:

Patch Plot

I can't find the appropriate parameter to change them to black. Has anyone an idea of how to do that?

Here is a full example:

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pagestyle{empty}

\begin{document}

\begin{figure}[htb]
\centering
  \begin{tikzpicture}
    \begin{axis}[%
      width=0.5\linewidth,
      height=0.5\linewidth,
      view={-213.5}{18},
      scale only axis,
      xmin=0,
      xmax=1,
      ymin=0,
      ymax=1,
      zmin=0,
      zmax=1,
      axis x line*=bottom,
      axis y line*=left,
      axis z line*=left]

    \addplot3[area legend,patch,forget plot,patch type=triangle,color=white,opacity=0.8]
      table[row sep=crcr, point meta=\thisrow{c}] {%
      x     y   z   c\\
      0     0   0   0\\
      0     0.3 1   0\\
      0.3   0   0.5 0\\};
    \end{axis}
  \end{tikzpicture}%
\end{figure}

\end{document}
2
  • Will 'draw=<desired colour>' help? I cannot test this since you didn't provide MWE.
    – Zarko
    Sep 1, 2014 at 18:17
  • Sorry, I added a full example. Draw does not help.
    – Simon
    Sep 2, 2014 at 6:43

2 Answers 2

8

You can change the color of the edge lines by setting faceted color=<color>, or disable them completely by setting faceted color=none.

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pagestyle{empty}

\begin{document}

  \begin{tikzpicture}
    \begin{axis}[%
      view={-213.5}{18},
      xmin=0,
      xmax=1,
      ymin=0,
      ymax=1,
      zmin=0,
      zmax=1
      ]

    \addplot3[
            patch,
            patch type=triangle,
            color=red!25,
            faceted color=black
        ]
      table[row sep=crcr, point meta=\thisrow{c}] {%
      x     y   z   c\\
      0     0   0   0\\
      0     0.3 1   0\\
      0.3   0   0.5 0\\};
    \end{axis}
  \end{tikzpicture}%
\end{document}
0
0

I found out that the color can be specified with the c argument of the table. As changing the values for every triangle is quite tedious, a simple (but not very elegant) solution is to modify the underlying color map of the axis:

colormap={mymap}{rgb=(0,0,0); rgb=(0,0,0)}

Now every edge is drawn in black.

1
  • 1
    I see you've unaccepted my answer and accepted yours instead. Could you explain why you prefer this solution over the faceted color approach?
    – Jake
    Sep 8, 2014 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.