為大型資料表圖中的點新增點標籤

為大型資料表圖中的點新增點標籤

資料表:(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}

在此輸入影像描述

相關內容