
나는 쓰고 싶다\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에서는 두 개의 중첩된 주석을 표시합니다. 빨간색 막대 위의 그래프 내부에 있는 글머리 기호입니다. 그리고 전설에 대한 감마.
\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}