我尝试从 CSV 中的 pgfplot 的自定义位置添加标题(https://drive.google.com/file/d/1xnF8rG9J50ZIxl9K04k6nksvjWoWrfHe/view?usp=sharing) 文件,但什么都没有出来。实际上,我尝试了几种方法……任何帮助都值得赞赏。这是我的代码:
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\usepackage{filecontents}
\begin{document}
\pgfkeys{/pgf/number format/.cd,1000 sep={\,}}
\begin{tikzpicture}
\begin{axis}%[ xlabel=Pixels, ylabel=pixels]
\addplot[color=blue, only marks, mark size=0.3pt] table[y=yval, x=xval, col sep=tab]{data_g.csv};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
有多种选择,您可以使用legend
或简单地使用node
,这是一个例子
\documentclass[border = 5pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{tikzpicture}
\begin{axis}[
samples = 500,
domain = 0 : 200,
xmin = 0, xmax = 250,
ymin = 0, ymax = 250,
]
\addplot[color = blue, only marks, mark size = 0.3pt] ({x + 10 * (1 - 2 * rand)}, {x + 10 * (1 - 2 * rand)});
\node at (axis cs:250,250) [anchor = north east] {Correlation coefficient: 0.923367};
\end{axis}
\end{tikzpicture}
\end{document}