TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to draw a logarithmically scaled timeline with TikZ. I tried starting from a snippet from chronlogy.sty:

\begin{tikzpicture}[baseline={(current bounding box.north)}]%
   \draw [|->] (0,0) -- (\thedeltayears*\unit+\unit, 0);%
   \foreach \x in {1,...,\thedeltayears}%
    \draw[xshift=\x*\unit] (0,-.1\unit) -- (0,.1\unit);%
  \foreach \x in {\thestepstart,\thestep,...,\thestepstop}{%
    \draw[xshift=\xstop] (0,-.3\unit) -- (0,.3\unit);%
    \node at (\xstop,0) [below=.2\unit] {\x};}}{%

The horizontal axis should look like the x-axis of a logarithmic plot with main ticks labeled ...,10^-2,10^-1,10^0,10^1,... and minor ticks without lables at a position corresponding to log10 of 2*10^-2, 3*10^-2, ... etc. Since the lower and upper limits should be customizable I need to implement an appropriate scaling function in TikZ. However, I already fail to alter the simple computation xshift=\x*\unit to something like xshift=log10(pow(10,\x))*\unit. How can I realize non-elementary computations in this place? Note that I consciously avoid the builtin \begin{axis}, because eventually I want to add labels and a second axis with different units etc. I also tried using \pgfmathparse and \pgfmathresult with equal success.

share|improve this question
up vote 4 down vote accepted

One can put the labels he wants.

enter image description here




\draw (0,0)--(9,0) ;

\foreach \n [count=\m from -2] in {0,...,8} {%
    \draw[thick] (\n,4pt)
        node[anchor=south,text depth=.5em]
        -- (\n,-4pt) 
        node[anchor=north,text height=.9em]
        {\scriptsize\pgfmathprintnumber\L}  ;
    \foreach \i [evaluate={\x=log10(\i)}] in {1,2,...,10}
        {\draw (\n+\x,-2pt) -- (\n+\x,+2pt) ; }
    \xdef\L{\L 0}   
    \draw[thick] (9,4pt)
        node[anchor=south,text depth=.5em]
        -- (9,-4pt) 
        node[anchor=north,text height=1em]
        {\scriptsize\pgfmathprintnumber\L}  ;

share|improve this answer
Your example works, but any minor modification (in the computations) I try fails. It seems I am affected by this bug tex.stackexchange.com/questions/33082/… . – highsciguy May 12 '14 at 20:32
@highsciguy Could you give me an example, then I try to adapt my code. – Tarass May 13 '14 at 17:23
Since this looks pretty advanced now, I decided to use it as a basis instead of the chronology package. I would like to implement the \unit which is used by chronology (it is passed as an argument to the environment defined by this package and necessary to be able to scale the graph to the desired size). When I add \newlength{\unit}\setlength{\unit}{1pt}, I can e.g. change (\n,4pt) to (\n,4*\unit) and it works. But changing {\draw (\n+\x,-2pt) -- (\n+\x,+2pt) ; } in the same way (I.e. multiplying all length by \unit) fails. Why is that? – highsciguy May 16 '14 at 13:55
Try \unit*2 and or -\unit*4. – Tarass May 16 '14 at 14:09

You can teach PGFPlots to just draw a single axis (instead of a box) without any plots:


    hide y axis,
    ymin=0, ymax=1,
    xtick align=center,
    axis x line*=bottom,
    enlarge x limits={abs=\pgflinewidth, upper}
share|improve this answer

Your Answer


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.