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/
187 stars 33 forks source link

Warning: The ticklabel anchor cannot be determined, the normal vector and the unit y vector are almost parallel #468

Open maxchendt opened 7 months ago

maxchendt commented 7 months ago

If I comment out any one of the tikzpicture, there is no warning. This Warning has been seen in https://tex.stackexchange.com/q/410445

\documentclass[tikz,margin=5pt]{standalone}
\usepackage{tikz,xcolor, pgfplots}
%\usepackage{amsmath,amsfonts,amssymb,amsthm}
\pgfplotsset{compat=1.18}

% for testing 
\begin{document}

%https://tex.stackexchange.com/q/139686 Controlling Orientation in 3D PGF Plots
\begin{tikzpicture}
\begin{axis}[
    xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    x={(-0.3cm,-0.3cm)}, y={(.5cm,0.0cm)}, z={(0cm,.1cm)},
    axis lines=middle, axis on top,
    xtick={-2,2}, ytick={-2,2},ztick={16,32},
    enlargelimits=true
    ]
\addplot3[surf, thick, color=green, domain=-4:4] {x^2+y^2};

\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[
    xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    x={(1cm,0cm)}, y={(0.317cm,0.217cm)},  z={(0cm,0.17cm)},
    axis lines=middle, axis on top,
    %https://tex.stackexchange.com/q/410445 Warning: The ticklabel anchor cannot be determined, the normal vector and the unit x vector are almost parallel
    xtick={-2,2}, ytick={-2,2},ztick={16,32},
    enlargelimits=true
    ]
\addplot3[surf, thick, color=green, domain=-4:4] {x^2+y^2};

\end{axis}
\end{tikzpicture}

\end{document}

compiling outputs

Package pgfplots notification 'compat/show suggested version=true': document ha
s been generated with the most recent feature set (\pgfplotsset{compat=1.18}).

[1]

Package pgfplots Warning: the ticklabel anchor cannot be determined, the normal
 vector -(0.38263pt,0.92383pt) and the unit y vector (0.82535pt,0.56494pt) are 
almost parallel (abs(cos(angle)) = 0.83769pt)! on input line 37.

Package pgfplots Warning: the ticklabel anchor cannot be determined, the normal
 vector -(0.38263pt,0.92383pt) and the unit y vector (0.82535pt,0.56494pt) are 
almost parallel (abs(cos(angle)) = 0.83769pt)! on input line 37.

Package pgfplots Warning: the ticklabel anchor cannot be determined, the normal
 vector -(0.38263pt,0.92383pt) and the unit y vector (0.82535pt,0.56494pt) are 
almost parallel (abs(cos(angle)) = 0.83769pt)! on input line 37.

Package pgfplots Warning: the ticklabel anchor cannot be determined, the normal
 vector -(0.38263pt,0.92383pt) and the unit y vector (0.82535pt,0.56494pt) are 
almost parallel (abs(cos(angle)) = 0.83769pt)! on input line 37.

Package pgfplots Warning: the ticklabel anchor cannot be determined, the normal
 vector -(-0.38263pt,-0.92383pt) and the unit y vector (0.82535pt,0.56494pt) ar
e almost parallel (abs(cos(angle)) = 0.83769pt)! on input line 37.

Package pgfplots Warning: the ticklabel anchor cannot be determined, the normal
 vector -(-0.38263pt,-0.92383pt) and the unit y vector (0.82535pt,0.56494pt) ar
e almost parallel (abs(cos(angle)) = 0.83769pt)! on input line 37.
muzimuzhi commented 7 months ago

Some caches set globally are not reset. Try this patch to \pgfplotspoint@initialisation

\documentclass[tikz,margin=5pt]{standalone}
\usepackage{tikz,xcolor, pgfplots}
\pgfplotsset{compat=1.18}

\usepackage{xpatch}
\makeatletter
% cache@2v2 and friends are not initialized in \pgfplotspoint@initialisation
\xapptocmd\pgfplotspoint@initialisation{%
  % other z-axis variables are initialised unconditionally too
  % \ifpgfplots@threedim
    \pgfplotspoint@initialise@axis@cache02%
    \pgfplotspoint@initialise@axis@cache12%
    \pgfplotspoint@initialise@axis@cache22%
    \pgfplotspoint@initialise@axis@cache20%
    \pgfplotspoint@initialise@axis@cache21%
  % \fi
}{}{\PatchFailed}

\def\pgfplotspoint@initialise@axis@cache#1#2{%
  \global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@v#1#2\endcsname\relax
  \global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@#1v#2\endcsname\relax
  \global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@#1#2v\endcsname\relax
}
\makeatother

\begin{document}
%https://tex.stackexchange.com/q/139686 Controlling Orientation in 3D PGF Plots
\begin{tikzpicture}
\begin{axis}[
    xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    x={(-0.3cm,-0.3cm)}, y={(.5cm,0.0cm)}, z={(0cm,.1cm)},
    axis lines=middle, axis on top,
    xtick={-2,2}, ytick={-2,2},ztick={16,32},
    enlargelimits=true
    ]
\addplot3[surf, thick, color=green, domain=-4:4] {x^2+y^2};

\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[
    xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    x={(1cm,0cm)}, y={(0.317cm,0.217cm)},  z={(0cm,0.17cm)},
    axis lines=middle, axis on top,
    %https://tex.stackexchange.com/q/410445 Warning: The ticklabel anchor cannot be determined, the normal vector and the unit x vector are almost parallel
    xtick={-2,2}, ytick={-2,2},ztick={16,32},
    enlargelimits=true
    ]
\addplot3[surf, thick, color=green, domain=-4:4] {x^2+y^2};

\end{axis}
\end{tikzpicture}

\end{document}