Change edge color of pgfplots patches

2,177

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}
Share:
2,177

Related videos on Youtube

Simon
Author by

Simon

Updated on August 01, 2022

Comments

  • Simon
    Simon over 1 year

    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}
    
    • Zarko
      Zarko about 9 years
      Will 'draw=<desired colour>' help? I cannot test this since you didn't provide MWE.
    • Simon
      Simon about 9 years
      Sorry, I added a full example. Draw does not help.
  • Jake
    Jake about 9 years
    I see you've unaccepted my answer and accepted yours instead. Could you explain why you prefer this solution over the faceted color approach?