如何绘制带箭头的数轴

如何绘制带箭头的数轴

我在使用 TiKz 绘制正确的图片时遇到了麻烦。下面是我开始的方法:

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows}

\begin{document}

\tikzset{->-/.style={decoration={
  markings,
  mark=at position #1 with {\arrow{<}}},postaction={decorate}}}

\begin{tikzpicture}
% a straight line segment
\draw[latex-] (-2,0) -- (0,0);
\draw[->-=.3] (0,0) -- (1,0);
\draw[->-=.6] (0,0) -- (1,0);
\draw[-latex] (1,0) -- (2,0);
% the ticks and their labels
\foreach \x  in {-1,...,1}
  \draw[xshift=\x cm] (0pt,2pt) -- (0pt,-1pt) node[below,fill=white] {\the\numexpr\x +1\relax};
\end{tikzpicture}

\end{document}

但我希望我的图片看起来像这样:

在此处输入图片描述

我怎样才能使数字正确显示,并且还能制作弯曲的箭头?

答案1

像这样?

在此处输入图片描述

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows}

\begin{document}

\tikzset{->-/.style={decoration={
  markings,
  mark=at position #1 with {\arrow{>}}},postaction={decorate}}}

\begin{tikzpicture}
% a straight line segment
\draw[latex-] (-2,0) -- (0,0);
\draw[->-=.3] (0,0) -- (1,0);
\draw[->-=.6] (0,0) -- (1,0);
\draw[-latex] (1,0) -- (2,0);
% the ticks and their labels
\foreach \x [count=\i start from 0] in {-1,...,1}
  \draw[xshift=\x cm] (0pt,2pt) -- (0pt,-1pt) node[below,fill=white] (\i) {\x};

\draw[->] (2) to [out=-95, in=-85] (0);
\draw[<-] (.25mm,1mm) arc(-85:265:3mm);
\end{tikzpicture}

\end{document}

相关内容