使用 pgfplots 创建此图

使用 pgfplots 创建此图

在此处输入图片描述

我正在尝试重新创建所示的图表。我可以生成数字线和标签,但是弯曲的箭头线有问题。提前致谢。MWE 在下面

\begin{tikzpicture}
      \begin{axis}[height=3cm,width=10cm,
  axis y line=none,
  axis lines=left,
  axis line style={-},
  xmin=-4.5,   xmax=3.5,   ymin=0,   ymax=1,
  restrict y to domain=0:1,
  xtick={-4,3},xticklabels={$-4\,m$,$3\,m$},                                            
  scatter/classes={                                   a= 
  {mark=*,draw=black,fill=white},b={mark=*,black,fill=white},c= 
  {mark=*,black,fill=white}
   },   point meta=explicit symbolic,
  ]

 \addplot[scatter] table [y expr=0,meta index=1, header=false] {
 -4 a
 3  b
 0  c
 };

% the labels
\node[coordinate,label=above:{$B$}] at (axis cs:3,0.2) {};
\node[coordinate,label=above:{$A$}] at (axis cs:-4,0.2) {};
\node[coordinate,label=above:{$O$}] at (axis cs:0,0.2) {};
\node[coordinate,label=below:{$t=6$}] at (axis cs:-4,0.2) {};
\node[coordinate,label=below:{$t=0$}] at (axis cs:0,0.2) {};
\node[coordinate,label=below:{$t=2$}] at (axis cs:-4,0.2) {};
\node[coordinate,label=above:{$4\,m$}] at (axis cs:-2,0.2) {};
\node[coordinate,label=above:{$3\,m$}] at (axis cs:1.5,0.2) {};
\end{axis}
\end{tikzpicture}

答案1

在此处输入图片描述

\documentclass[tikz,border=3.14pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\draw[ultra thick] (-4.5,0) -- (3.5,0);
\foreach \X/\L in {-4/A,0/O,3/B}
{\draw[fill=white] (\X,0) circle (1pt) node[above] (\L){\L};}
\node[below=1pt of A] (A1) {$t=6$};
\node[below=1pt of O] (O1) {$t=0$};
\node[below=1pt of B] (B1) {$t=2$};
\node[below=0pt of A1.south west,anchor=north west] (A2) {$x(6)=-4$};
\node[below=0pt of O1.south west,anchor=north west] (O2) {$x(0)=0$};
\node[below=0pt of B1.south west,anchor=north west] (B2) {$x(2)=3$};
\draw[fill=black] (0,1) coordinate(O3) circle (1pt);
\draw[-latex] (O3)--++(1.5cm,0);
\draw[-latex] (O3)--++(2.5cm,0) to[out=0,in=0,looseness=2]  ++(0,0.5cm)
-- ++(-6.5cm,0);
\end{tikzpicture}
\end{document}

相关内容