如何给轴添加“点”?

如何给轴添加“点”?

我想给轴添加任意长度,但我不知道如何做。

\documentclass[10pt,a4paper,french]{article}
\usepackage{tikz}

\pgfkeys{/tikz/.cd,
  NbGrad/.store in=\NbGrad,
  Noze/.store in=\Noze,
  Noze=.5cm,
   }

\begin{document}

\begin{tikzpicture}[%
    >=stealth,x=6cm,font=\footnotesize,NbGrad=6]

\draw [->] (0,0)--(1+\Noze,0)  ;

\foreach \x in {0,1,...,\NbGrad} {%
    \coordinate (\x) at (\x/\NbGrad,0) ;
    \draw [very thin] (\x/\NbGrad,+2pt)--(\x/\NbGrad,-2pt) ;

    \pgfmathsetmacro\result{2 + \x / 10}
    \node[above=1pt,text depth=1.5pt]  at (\x)%
        {\pgfmathprintnumber[precision=1,fixed,use comma]{\result}};

    } ;

\end{tikzpicture}
\end{document}

答案1

您可以使用calc库:

\documentclass[10pt,a4paper,french]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\pgfkeys{/tikz/.cd,
  NbGrad/.store in=\NbGrad,
  Noze/.store in=\Noze,
  Noze=2.5cm,
   }

\begin{document}

\begin{tikzpicture}[%
    >=stealth,x=6cm,font=\footnotesize,NbGrad=6]

\draw [->] (0,0)--($(1,0) +(\Noze,0)$)  ;

\foreach \x in {0,1,...,\NbGrad} {%
    \coordinate (\x) at (\x/\NbGrad,0) ;
    \draw [very thin] (\x/\NbGrad,+2pt)--(\x/\NbGrad,-2pt) ;

    \pgfmathsetmacro\result{2 + \x / 10}
    \node[above=1pt,text depth=1.5pt]  at (\x)%
        {\pgfmathprintnumber[precision=1,fixed,use comma]{\result}};

    } ;

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容