「マークのみ」プロパティを使用してプロットされた関数のポイントにラベルを付けるにはどうすればよいですか?

「マークのみ」プロパティを使用してプロットされた関数のポイントにラベルを付けるにはどうすればよいですか?

特定のポイントのみを表示し、これらのポイントにラベルを付ける関数を tikzpicture で描画しようとしています。

私のコードは次のようになります:

\documentclass[12pt,a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{fit}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{patterns, patterns.meta}

\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{backgrounds, intersections}

\begin{document}

\begin{tikzpicture}[scale=1]
    \begin{axis}[
        width=0.6\linewidth,
        xmin=-72,
        xmax= 24,
        ymin=-16,
        ymax= 40,
        x=0.1cm,
        y=0.1cm,
        xtick distance=8,
        ytick distance=8,
        axis lines=middle,
        xlabel=$\Re z_n$,
        ylabel=$\Im z_n$,
        grid={both}]        
            
        \addplot[blue, only marks, domain=1:12, samples=12] ({sqrt(2)^(\x)*cos(deg(\x*pi/4))},{sqrt(2)^(\x)*sin(deg(\x*pi/4))});
\end{tikzpicture}

\end{document}

このコードはポイントを描画します。これらのポイントにラベルを付けたいのですが、次のコードを試しましたが、うまくいきません。助けていただければ幸いです。

\foreach \x in {1,...,12} 
    \draw[blue] ({sqrt(2)^(\x)*cos(deg(\x*pi/4))},{sqrt(2)^(\x)*sin(deg(\x*pi/4))}) node[above]  {$z_\x$};

私の質問は、addplot 関数にラベルを直接追加できますか、それともラベルを追加するループを記述する必要がありますか? また、正しいコードはどのようになりますか。

ご協力いただければ幸いです。

答え1

こんな感じ?nodes near coords*={$z_{\coordindex}$},

コード

\documentclass[boreder=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[scale=1]
    \begin{axis}[
        width=0.6\linewidth,
        xmin=-72,
        xmax= 24,
        ymin=-16,
        ymax= 40,
        x=0.1cm,
        y=0.1cm,
        xtick distance=8,
        ytick distance=8,
        axis lines=middle,
        xlabel=$\Re z_n$,
        ylabel=$\Im z_n$,
        grid={both},
        nodes near coords*={$z_{\coordindex}$},
        ]            
        \addplot+[blue, only marks,  domain=1:12, samples=12] ({sqrt(2)^(\x)*cos(deg(\x*pi/4))},{sqrt(2)^(\x)*sin(deg(\x*pi/4))});
    \end{axis}
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報