tikz でプロット外の特定の位置にテキストを配置する方法

tikz でプロット外の特定の位置にテキストを配置する方法

書きたい\gamma 私の伝説の上にプロット (画像に表示) は、以下に示すコードを使用して生成されます。私は通常、\node at (axis cs: co-ordinate x,co-ordinate y) {text}プロットの を使用します。凡例はプロットの外側にあるため、 を使用して凡例の上の点にアクセスする方法がわかりません\node

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

\begin{document}


\begin{tikzpicture}
\begin{loglogaxis}[
 %  scale=0.8,
 %  width=\columnwidth,
 %  baseline,
    ylabel={$G(\gamma,t) \:\: \mathrm{(Pa)}$},
    xlabel= t (s),
    legend entries ={0.1,0.2,0.4,0.8},
    legend style={at={(1.3,0.5)},anchor=east,font=\small},
]

\addplot [color=red,line width=1.5pt] table [x=time,y=m01,row sep=newline] {relaxationExpDatafor65v.dat};

\addplot [color=green,line width=1.5pt] table [x=time,y=m02,row sep=newline] {relaxationExpDatafor65v.dat};

\addplot [color=blue,line width=1.5pt] table [x=time,y=m04,row sep=newline] {relaxationExpDatafor65v.dat};

\addplot [color=cyan,line width=1.5pt] table [x=time,y=m08,row sep=newline] {relaxationExpDatafor65v.dat};


%%fits

\addplot [color=black,line width=1pt,densely dashed] table [x=time,y=m01,row sep=newline] {relaxationExpDataPredfor65v.dat};

\addplot [color=black,line width=1pt,densely dashed] table [x=time,y=m02,row sep=newline] {relaxationExpDataPredfor65v.dat};

\addplot [color=black,line width=1pt,densely dashed] table [x=time,y=m04,row sep=newline] {relaxationExpDataPredfor65v.dat};

\addplot [color=black,line width=1pt,densely dashed] table [x=time,y=m08,row sep=newline] {relaxationExpDataPredfor65v.dat};



\end{loglogaxis}
\end{tikzpicture}

\end{document}

生成されたプロット

コード内で呼び出される .dat ファイルは必要ないことを願います (正直に言うと、このコミュニティでの最初の質問なので、アップロード方法がわかりません)。ご協力ありがとうございます。

答え1

label=above:$\gamma$定義を追加するだけですlegend style

例として、Steven が提供したコードを使用しました。

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
      \begin{tikzpicture}
        \begin{axis}[
            width  = 1*\textwidth,
            height = 4.5cm,
            major x tick style = transparent,
            ybar=1*\pgflinewidth,
            bar width=13pt,
            symbolic x coords={A,B,C,D},
            xtick = data,
            enlarge x limits=0.25,
            ymax=15,
            ymin=0,
            legend cell align=left,
            legend style={
                    at={(1,1.05)},
                    anchor=south east,
                    column sep=1ex,
                    label=above:$\gamma$ %<--------------------
            }
        ]
            \addplot[style={fill=red,mark=none}]
                coordinates {(A, 4.44) (B,0.1) (C,4.37) (D,4.07)};
            \addplot[style={fill=green,mark=none}]
                coordinates {(A, 0.4) (B,0.8) (C,0.3) (D,0.5)};
            \addplot[style={fill=blue,mark=none}]
                coordinates {(A, 0.2) (B,0) (C,0.9) (D,0.8)};
            \addplot[style={fill=yellow,mark=none}]
                coordinates {(A, 9.59) (B,0.2) (C,8.86) (D,8.62)};
        \legend{C1,C2,C3,C4}
      \end{axis}
    \end{tikzpicture}%
\end{document}

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

答え2

内に答えが見つからない場合はtikz、環境の外側にコードをラップする方法がありますtikzpicture。あなたの例をコンパイルするには不十分だったので、別の質問から同様の例を取得しました。

の回答に基づいてグループ化された棒グラフに注釈を付ける注釈の位置とテキストを変更するだけで、注釈を追加できます。この MWE では、2 つのネストされた注釈を示しています。グラフ内の赤いバーの上の箇条書きと、凡例の上のガンマです。

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{stackengine}[2013-09-11]
\begin{document}
    \begin{figure}[]
     \stackinset{c}{-3.92cm}{b}{1.52cm}{$\bullet$}{%
     \stackinset{r}{.6cm}{t}{-.3cm}{$\gamma$}{%
      \begin{tikzpicture}
        \begin{axis}[
            width  = 1*\textwidth,
            height = 4.5cm,
            major x tick style = transparent,
            ybar=1*\pgflinewidth,
            bar width=13pt,
            symbolic x coords={A,B,C,D},
            xtick = data,
            enlarge x limits=0.25,
            ymax=15,
            ymin=0,
            legend cell align=left,
            legend style={
                    at={(1,1.05)},
                    anchor=south east,
                    column sep=1ex
            }
        ]
            \addplot[style={fill=red,mark=none}]
                coordinates {(A, 4.44) (B,0.1) (C,4.37) (D,4.07)};
            \addplot[style={fill=green,mark=none}]
                coordinates {(A, 0.4) (B,0.8) (C,0.3) (D,0.5)};
            \addplot[style={fill=blue,mark=none}]
                coordinates {(A, 0.2) (B,0) (C,0.9) (D,0.8)};
            \addplot[style={fill=yellow,mark=none}]
                coordinates {(A, 9.59) (B,0.2) (C,8.86) (D,8.62)};
        \legend{C1,C2,C3,C4}
      \end{axis}
    \end{tikzpicture}%
   }}
  \end{figure}
\end{document}

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

関連情報