为大数据表的绘图中的点添加点标签

为大数据表的绘图中的点添加点标签

数据表:(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}

在此处输入图片描述

相关内容