pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
198 stars 33 forks source link

patch plot shader interp issue #471

Open lucafadigati opened 7 months ago

lucafadigati commented 7 months ago

Hi, I need to plot a velocity magnitude distribution over a 2D triangular mesh, hence I have used patch plot as follows using the jet colormap. I used the shader=interp to have a smooth color variation over the domain but there is an issue in the color interpolation because there are some "darker edges" in the picture as shown in the attached image. Using shader=flat, everything is fine. Is it an issue of the Gouraud shading?

Best regards, Luca

Screenshot from 2024-02-23 13-49-31

\begin{tikzpicture}[font=\small, scale=0.9]

\begin{axis}[
    every axis/.append style={font=\normalsize},
    hide axis,
    scale only axis,
    axis equal image,
    colorbar horizontal,
    colormap/jet,
    point meta min=0,
    point meta max=2300,
]

    \addplot [
    patch,
    shader=interp,
    patch table with individual point meta={tri.dat}
    ]
    table
    {points.dat};

\end{axis}

\end{tikzpicture}
muzimuzhi commented 7 months ago

Please make your example complete, so others could typeset and dig into it.

lucafadigati commented 7 months ago

In the uploaded the following tex file which contains a minimal working example which creates a figure that highlights the issue. To avoid too long execution time, I have plot only the region that has the problem.

Zooming in the output pdf file, the "bad colored" triangle are visible between the cyan and yellow region. These triangles seem to have a darker edge and a lighter ones.

example.zip

\documentclass[a4paper]{standalone}

\usepackage{tikz, tikz-3dplot}
\usepackage{pgfplotstable}
\usepackage{pgfplots}

\usetikzlibrary{positioning,calc,tikzmark,patterns,patterns.meta,decorations,decorations.text,decorations.pathmorphing,backgrounds,math}

\begin{document}

\begin{tikzpicture}[font=\small, scale=0.9]

    \begin{axis}[
        every axis/.append style={font=\normalsize},
        hide axis,
        scale only axis,
        axis equal image,
        xmin=0.28, xmax=0.4,
        ymin=0, ymax=0.05,
        colorbar horizontal,
        colormap/jet,
        point meta min=0,
        point meta max=2300,
        colorbar style={
           at={(0,1.3)},anchor=south west,
           height=0.4cm,
           title=$u$,
           font = \normalsize,
        }
    ]

        \addplot [
        patch,
        shader=interp,
        patch table with individual point meta={Umag_tri_.dat}
        ]
        table
        {points_.dat};

    \end{axis}
    \end{tikzpicture}

\end{document}