1

enter image description here

I am trying to recreate the diagram shown. I can generate the numberline and labels, however, the curved arrowed line is proving problematic. Thanks in advance. MWE is below

\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
    Show a minimal working example (MWE) of what you have done so far. Also I think this diagram is better created using TikZ than pgfplots. – Henri Menke Apr 18 '18 at 1:01
  • Could you please tell me why you want to use pgfplots for that? It would be so much simpler with TikZ, I think. – user121799 Apr 18 '18 at 1:50
  • Working with ith tikz would be ok as well. I use pgfplots for most of my graphing, so I thought I may as well stay with pgfplots. – Anthony Macks Apr 18 '18 at 1:53
2

enter image description here

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.