DominikPeters / tikz.dev-issues

Feedback, suggestions, and bug reports for tikz.dev
1 stars 0 forks source link

pgfplots: Wrong colormap in first `mesh/color input` example #29

Closed muzimuzhi closed 4 months ago

muzimuzhi commented 4 months ago

Describe the bug

In the first example of /pgfplots/mesh/color input, the main plot uses a colormap different from the colorbar next to it, hence different from that in the PDF manual.

Screenshots

I can get the colormap in PDF with

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.18}
\usepgfplotslibrary{patchplots}

\begin{document}
% Preamble: \pgfplotsset{width=7cm,compat=1.18}
% \usepgfplotslibrary{patchplots}
\begin{tikzpicture}
\begin{axis}[small,view={0}{90},colorbar]
    \addplot3 [
        surf,
        shader=interp,
        patch type=bilinear,
    ] coordinates {
        (0,0,0) (1,0,0)

        (0,1,0) (1,1,1)
    };
\end{axis}
\end{tikzpicture}
\end{document}
muzimuzhi commented 4 months ago

The last example of /pgfplots/contour lua has a similar problem.

% !TeX program = lualatex
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.18}

\begin{document}
% Preamble: \pgfplotsset{width=7cm,compat=1.18}
\begin{tikzpicture}
\begin{axis}
    \addplot3 [
        surf,
        shader=interp
    ] coordinates {
        (0,0,0) (1,0,0)   (2,0,0)   (3,0,0)

        (0,1,0) (1,1,0.6) (2,1,0.7) (3,1,0.5)

        (0,2,0) (1,2,0.7) (2,2,0.8) (3,2,0.5)
    };
    \addplot3 [
        contour lua,
        z filter/.code={\def\pgfmathresult{1}},
    ] coordinates {
        (0,0,0) (1,0,0)   (2,0,0)   (3,0,0)

        (0,1,0) (1,1,0.6) (2,1,0.7) (3,1,0.5)

        (0,2,0) (1,2,0.7) (2,2,0.8) (3,2,0.5)
    };
\end{axis}
\end{tikzpicture}
\end{document}
DominikPeters commented 4 months ago

There must be some PDF trickery going on with all these examples. Apple's Preview app shows an empty plot:

image

and the Chrome browser's PDF viewer shows the same thing as in the HTML version's image:

image

and evidently so does pdftocairo which is doing the conversion to SVG and PNG. Not sure what to do about it and whether there exist any easily command line callable viewers that do it "correctly" -- I don't think Adobe Acrobat will be very helpful.

EDIT: ImageMagick does it correctly.

muzimuzhi commented 4 months ago

MuPDF does it correctly too. mutool convert -o output.png input.pdf

doc: https://mupdf.readthedocs.io/en/latest/mutool-convert.html

muzimuzhi commented 4 months ago

I can confirm this issue and the similar #30 and #31 are all fixed in "HTML version last updated: 2024-02-26". Thank you.