你好呀
z buffer = {sort}
尝试使用自定义选项向图表添加选项colormap
会生成错误:
梅威瑟:
\documentclass{article}
% pgfplots
\usepackage{pgfplots}
\pgfplotsset{
compat = newest,
width = .95\linewidth, % width
height = .22\textheight, % height
samples = 20,
% Color Map
colormap = {cool}{
color(0cm)=(green!70!white!40!black);
color(2cm)=(green!70!white!70!black);
color(5cm)=(green!70!white!90!black)
},
}
\begin{document}
\pgfplotsset{
height = 0.4\pageheight,
width = 0.4\textwidth,
}
\begin{tikzpicture}
\begin{axis}
[
hide axis,
z buffer = {sort},
]
% Hiperbole
\addplot3 [
% Aparence
surf,
opacity = 0.5,
fill opacity = 1,
faceted color = white,
shader = faceted interp,
% Scope
data cs = cart, % cart/polar/polarrad
samples = 10,
% Variable
variable = \u,
variable y = \v,
domain = -1:1,
domain y = 0:360,
](
{cosh(u)*cos(v)},
{cosh(u)*sin(v)},
{sinh(u)}
);
\end{axis}
\end{tikzpicture}
\end{document}
同时激活定义和选项会产生几个错误colormap
:z buffer
/Users/stack q/stack_q.tex:56: Package pgfplots Error: No such element: \pgfplotsarrayselect-1\of{pgfpl@cm@cool@X}.
See the pgfplots package documentation for explanation.
Type H <return> for immediate help.
...
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: You can't use `the letter b' after \advance.
<argument> ...olormapfind@rgb@X@left \advance \c@pgf@counta b
y1 \ifnum \c@pgf@counta <\...
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Missing number, treated as zero.
<to be read again>
<
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Missing number, treated as zero.
<to be read again>
\relax
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Missing number, treated as zero.
<to be read again>
\pgfplotscolormapfind@rgb@X@left
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Illegal unit of measure (pt inserted).
<to be read again>
\pgfplotscolormapfind@rgb@X@left
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Missing number, treated as zero.
<to be read again>
\pgfplotscolormapfind@rgb@X@left
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Illegal unit of measure (pt inserted).
<to be read again>
\pgfplotscolormapfind@rgb@X@left
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Package PGF Math Error: You've asked me to divide `67.37263' by `0.0', but I cannot divide any number by `0.0'.
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Arithmetic overflow.
\pgfmathdivide@ ...\pgfmath@x by\c@pgfmath@counta
\else \ifdim 0pt>\pgfmath@...
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Package pgfplots Error: No such element: \pgfplotsarrayselect-1\of{pgfpl@cm@cool}.
See the pgfplots package documentation for explanation.
Type H <return> for immediate help.
...
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: You can't use `the letter b' after \advance.
\pgfplotscolormapfind@precomputed@ ...pgf@counta b
y1 \ifnum \c@pgf@counta <\...
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Missing number, treated as zero.
<to be read again>
<
l.56 \end{axis}
/Users/stack q/stack_q.tex:56: Missing number, treated as zero.
<to be read again>
\relax
l.56 \end{axis}
Runaway argument?
\pgfplots@EOI \relax \pgffor@continuefalse \fi \fi \ifx \pgfplots@markers@visphase@name \ETC.
/Users/stack q/stack_q.tex:58: Paragraph ended before \pgfplots@loc@TMPb was complete.
<to be read again>
\par
l.58
/Users/stack q/stack_q.tex:59: Improper \prevdepth.
\newpage ...everypar {}\fi \par \ifdim \prevdepth
>\z@ \vskip -\ifdim \prevd...
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing } inserted.
<inserted text>
}
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing } inserted.
<inserted text>
}
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing } inserted.
<inserted text>
}
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing } inserted.
<inserted text>
}
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing } inserted.
<inserted text>
}
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing \endgroup inserted.
<inserted text>
\endgroup
l.59 \end{document}
/Users/stack q/stack_q.tex:59: Missing } inserted.
<inserted text>
}
l.59 \end{document}
/Users/stack q/stack_q.tex:59: LaTeX Error: \begin{tikzpicture} on input line 27 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.59 \end{document}
(./.build/stack_q.aux))
(\end occurred inside a group at level 3)
### semi simple group (level 3) entered at line 28 (\begingroup)
### semi simple group (level 2) entered at line 27 (\begingroup)
### semi simple group (level 1) entered at line 27 (\begingroup)
### bottom level
(\end occurred when \ifx on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
(\end occurred when \if on line 56 was incomplete)
答案1
显然,使用非均匀颜色图时,PGFPlots 中存在一个错误。偏移量被映射到区间 0-1000,从第一个偏移量开始,到最后一个偏移量结束,因此,对于您的情况:
0cm -> 0
2cm -> 400
5cm -> 1000
这些数字用于选择颜色。它们与均匀颜色图(0,500,1000)相差无几,因此我怀疑不均匀性是可以察觉的。如果外观看起来太亮/太暗,可以调整颜色本身或将更多颜色添加到列表中。
这是您的图表的统一版本:
\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
hide axis,
z buffer=sort,
colormap={mycool}{
color=(green!70!white!40!black)
color=(green!70!white!70!black)
color=(green!70!white!90!black)
},
]
\addplot3 [
surf,
variable=\u,
variable y=\v,
domain=-1:1,
domain y=0:360,
]( {cosh(u)*cos(v)} , {cosh(u)*sin(v)} , {sinh(u)} );
\end{axis}
\end{tikzpicture}
\end{document}