tikz極座標の点の色を変更する

tikz極座標の点の色を変更する

現在、極座標内の単一ポイントの色を変更するのに苦労しています。シリンダーを使用して HSV 色空間の視覚化を作成したいと考えています。

感謝pgfplots における円錐の HSV シェーディングpoint meta={symbolic={Hsb=v,u,u}}現在の座標から直接適切な色を取得するために使用できることを学びました。

しかし、シリンダーに変更すると、

Missing number, treated as zero.
<to be read again> 
LaTeX
Illegal unit of measure (pt inserted).
<to be read again> 
LaTeX

エラー。

現在のコードは次のとおりです:

\documentclass[tikz,border=3mm]{standalone} 
\usepackage{pgfplots}

\begin{document} 
\begin{axis}[axis equal, data cs=polar]
    
    \addplot3 [surf,
                domain=0:1,
                y domain=0:180,
               samples=20, %number of samples taken
               z buffer=sort,
               shader=interp,
               variable=\u,
               variable y=\v,
               point meta={symbolic={Hsb=u,v,v}}] % the origin of my errors
        (
            {v/2},
            {sin(v/2)},
            {u}
        );
    
    \end{axis}
\end{document}

シリンダーを生成する私のハッキーな方法が問題を引き起こしているのではないかと考えていますが、よくわかりません。

前もって感謝します

答え1

MWE を修正して を含めたようですね。後世のために言っておきますが、彩度の HSB "S" にも問題がありました。これは [0,1] の値を必要としますが、そこに[0,180]mesh/color input = explicit mathparse,を渡していました。\v

楽しみのために、完全なシリンダーが必要な場合は、ドメインを変更できます。

\documentclass[tikz,border=3mm]{standalone} 
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document} 
\begin{tikzpicture}
    \begin{axis}[axis equal, data cs=polar]
    \addplot3 [
        surf,
        domain = 0:1,
        y domain = 0:360,
        samples = 20, %number of samples taken
        z buffer = sort,
        shader = interp,
        variable = \u, variable y = \v,
        mesh/color input = explicit mathparse,
        point meta={symbolic={Hsb=v,1,u}},
        ] 
        ({v/2},{sin(v/2)},{u});
    \end{axis}    
\end{tikzpicture}
\end{document}

HSBカラーのオープントップシリンダー フルカラースペクトルの半円筒が必要な場合は、色相を 2 倍にします。

\documentclass[tikz,border=3mm]{standalone} 
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document} 
\begin{tikzpicture}
    \begin{axis}[axis equal, data cs=polar]
    \addplot3 [
        surf,
        domain = 0:1,
        y domain = 0:180,
        samples = 20, %number of samples taken
        z buffer = sort,
        shader = interp,
        variable = \u, variable y = \v,
        mesh/color input = explicit mathparse,
        point meta={symbolic={Hsb=2*v,1,u}},
        ] 
        ({v/2},{sin(v/2)},{u});
    \end{axis}    
\end{tikzpicture}
\end{document}

HSBカラーのオープントップ半円筒

答え2

私はもう一度コードを見てpgfplots における円錐の HSV シェーディングmesh/color input=explicit mathparse軸オプションに追加するのを忘れていたことに気付きました。

動作するコードは次のとおりです。

\documentclass[tikz,border=3mm]{standalone} 
\usepackage{pgfplots}

\begin{document} 
\begin{tikzpicture}

    \begin{axis}[axis equal, data cs=polar, mesh/color input=explicit mathparse] % the solution to my problem
    
    \addplot3 [surf,
                domain=0:1,
                y domain=0:180,
               samples=20, %number of samples taken
               z buffer=sort,
               shader=interp,
               variable=\u,
               variable y=\v,
               point meta={symbolic={Hsb=v,1,u}}]
        (
            {v/2},
            {sin(v/2)},
            {u}
        );
    
    \end{axis}
    
\end{tikzpicture}
\end{document}

コンパイルされた画像

関連情報