Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to add an arbitrary length to an axis, but I don't know how.

\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}
share|improve this question
    
I found this : \draw [->] (0,0)--(1,0)-- ++(\Noze,0) ; that works. –  Tarass Feb 15 at 12:21
    
Well, Paulo Cereda made an effort here, but it's probably not what you look for ;) chat.stackexchange.com/transcript/message/13789779#13789779 –  tohecz Feb 15 at 13:20
    
Exactly what I was looking for ! It became my online image. How to thank him ? ;-) –  Tarass Feb 15 at 14:24

1 Answer 1

up vote 3 down vote accepted

You can use calc library:

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

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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