![為大型資料表圖中的點新增點標籤](https://rvso.com/image/449640/%E7%82%BA%E5%A4%A7%E5%9E%8B%E8%B3%87%E6%96%99%E8%A1%A8%E5%9C%96%E4%B8%AD%E7%9A%84%E9%BB%9E%E6%96%B0%E5%A2%9E%E9%BB%9E%E6%A8%99%E7%B1%A4.png)
資料表:(X軸:跨中位移,Y軸:載重)https://pastebin.com/2WSvSBcn
我正在嘗試為該圖的特定點製作資料點標籤,類似於下圖:https://i.stack.imgur.com/lFsED.png
\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{document}
\pgfplotsset{width=10cm,compat=newest}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
xlabel={Displacement ($mm$)},
ylabel={Load ($kN$)},
legend style={legend pos=south east},
]
\addplot[smooth, solid]
table[x index=3,y index=1] {dat_25n02.txt};
\legend{25-N-0}
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
dat.txt 上面有 1000 多個數據點鏈接
答案1
這就是添加節點和標籤的方法。如果您有任何問題,請告訴我。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.18}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
xlabel={Displacement ($mm$)},
ylabel={Load ($kN$)},
legend style={legend pos=south east},
]
\addplot[smooth, solid]
table[x index=3,y index=1] {dat_25n02.txt};
\legend{25-N-0}
%%%%%%%%%%%%%%
% First node %
%%%%%%%%%%%%%%
\node [minimum size=0.3cm,inner sep=0pt,circle,fill=blue,pin={[pin distance=1cm]0: First point}] at (axis cs:0,0) {};
%%%%%%%%%%%%%%%
% second node %
%%%%%%%%%%%%%%%
\node [minimum size=0.3cm,inner sep=0pt,circle,fill=blue] at (axis cs:2.45,35.72) {};
%%%%%%%%%%%%%%
% Third node %
%%%%%%%%%%%%%%
\node [minimum size=0.3cm,inner sep=0pt,circle,fill=blue,pin={[pin distance=1cm]-15: Third point}] at (axis cs:4.09,79.74) {};
%%%%%%%%%%%%%%%
% Fourth node %
%%%%%%%%%%%%%%%
\node [minimum size=0.3cm,inner sep=0pt,circle,fill=blue,pin={[pin distance=1cm]-15: End of linear behaviour}] at (axis cs:5.49,108.58) {};
%%%%%%%%%%%%%
% Last node %
%%%%%%%%%%%%%
\node [minimum size=0.3cm,inner sep=0pt,circle,fill=blue,pin={[pin distance=1cm]200: Failure}] at (axis cs:70.77,134.77) {};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}