如何制作数轴?

如何制作数轴?

想要的东西

我想制作如上所示的数字轴。我该如何为 TeX 制作它?

提前致谢。

答案1

更短的解决方案

\documentclass[tikz]{standalone}

\begin{document}
  \begin{tikzpicture}[
      letter/.style={circle, minimum size=3pt, inner sep=0, outer sep=0, fill=black, label=below:#1},
      number/.style={fill=white, pos=.5}
  ]
      \draw (0,0) --
              node(A)[letter=A,pos=.2]{}
              node(C)[letter=C,pos=.6]{}
              node(B)[letter=B,pos=.8]{}
            (8,0)
      ;

      \draw[dashed]
          (A) to[bend left]      node[number]{2} (C)
          (C) to[bend right=50]     node[number]{1} (B)
          (A) to[bend left=50] node[number]{3} (B)
      ;
  \end{tikzpicture}
\end{document}

在此处输入图片描述

首先,在任意两点之间画一条线,这里我选择 (0,0) 和 (8,0)(长度为 8 的水平线)。在此过程中,您将按长度的一定百分比(在我们的例子中为 20、60 和 80)创建三个节点 AB 和 C。将它们命名为 (A) (B) 和 (C)。然后,要绘制虚线,请使用路径将它们连接起来,to并指定您希望它们为虚线和弯曲。在此过程中,您还会在中间创建一个带有数字标签的节点。

答案2

tikz 中的数轴

\documentclass{article}
\usepackage{pgf,tikz}
\pagestyle{empty}

\begin{document}
\begin{tikzpicture}[x=1.0cm,y=1.0cm]
\clip(-2.5,-1) rectangle (11.5,2.5);
\draw (-2,0)-- (3,0);
\draw (5,0)-- (10,0);
\draw [dash pattern=on 2pt off 2pt](-1,0)..controls (0.25,1) and (1,1) .. (2,0)  ;
\draw [dash pattern=on 2pt off 2pt](-1,0)..controls (-0.25,0.4) and (0.25,0.4) .. (1,0)    ;
\draw [dash pattern=on 2pt off 2pt](1,0)..controls (1.25,-0.35) and (1.75,-0.35) .. (2,0)  ;
\draw [dash pattern=on 2pt off 2pt](6,0)..controls (7,-1) and (8,-1) .. (9,0)  ;
\draw [dash pattern=on 2pt off 2pt](7,0)..controls (7.75,0.8) and (8.25,0.8) .. (9,0)    ;
\draw [dash pattern=on 2pt off 2pt](6,0)..controls (6.25,0.35) and (6.75,0.35) .. (7,0)  ;

\draw [fill=black] (-1,0) circle (1.5pt);
\draw[color=black] (-1,-0.3) node {$A$};
\draw [fill=black] (2,0) circle (1.5pt);
\draw[color=black] (2,-0.3) node {$C$};
\draw [fill=black] (1,0) circle (1.5pt);
\draw[color=black] (1,-0.3) node {$B$};
\draw [fill=black] (6,0) circle (1.5pt);
\draw[color=black] (6,-0.3) node {$C$};
\draw [fill=black] (7,0) circle (1.5pt);
\draw[color=black] (7,-0.3) node {$A$};
\draw [fill=black] (9,0) circle (1.5pt);
\draw[color=black] (9,-0.3) node {$B$};

\draw (0.6,0.75) node [fill=white]
{$3$};
\draw (0,0.32) node [fill=white]
{$2$};
\draw (1.5,-0.3) node [fill=white]
{$1$};
\draw (7.5,-0.75) node [fill=white]
{$5$};
\draw (8,0.6) node [fill=white]
{$3$};
\draw (6.5,0.25) node [fill=white]
{$2$};
\end{tikzpicture}

\end{document}

结果 在此处输入图片描述

相关内容