The last argument is optional, not mandatory and so should use brackets. It is not quite clear what is its purpose but it seems to allow scaling: the timeline is created in the size of arg #5 and then scaled to arg #4 (this also means that arg #4 shouldn't be too small.
\documentclass{article}
\usepackage{chronology}
\begin{document}
\begin{chronology}[5]{1983}{2010}{\textwidth}
\event{1984}{oneD}
\event[1985]{1986}{two}
\event{\decimaldate{25}{12}{2001}}{three}
\end{chronology}
abc
\begin{chronology}[5]{1983}{2010}{10cm}[\textwidth]
\event{1984}{oneD}
\event[1985]{1986}{two}
\event{\decimaldate{25}{12}{2001}}{three}
\end{chronology}
abc
abc
\begin{chronology}[5]{1983}{2010}{10cm}[0.2\textwidth]
\event{1984}{oneD}
\event[1985]{1986}{two}
\event{\decimaldate{25}{12}{2001}}{three}
\end{chronology}
abc
\end{document}
You can also use line width
to draw the colored rectangle.
And define the color shading within the \foreach
.
\documentclass{article}
\newcommand{\ImageWidth}{11cm}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,positioning, arrows.meta}
\begin{document}
\begin{tikzpicture}
% draw horizontal line
\draw[thick, -Triangle] (0,0) -- (\ImageWidth,0) node[font=\scriptsize,below left=3pt and -8pt]{years};
% draw vertical lines
\foreach \x in {0,1,...,10}
\draw (\x cm,3pt) -- (\x cm,-3pt);
\foreach \x/\descr in {4/t-2,5/t-1,6/t,7/t+1}
\node[font=\scriptsize, text height=1.75ex,
text depth=.5ex] at (\x,-.3) {$\descr$};
% colored bar up
\foreach \x/\perccol in
{1/100,2/75,3/25,4/0}
\draw[lightgray!\perccol!red, line width=4pt]
(\x,.5) -- +(1,0);
\draw[-Triangle, dashed, red] (5,.5) -- +(1,0);
% colored bar down
\foreach \x/\perccol in
{3/100,4/75,5/0}
\draw[lightgray!\perccol!green, line width=4pt]
(\x,-.7) -- +(1,0);
\draw[-Triangle, dashed, green] (6,-.7) -- +(1,0);
% braces
\draw [thick ,decorate,decoration={brace,amplitude=5pt}] (4,0.7) -- +(2,0)
node [black,midway,above=4pt, font=\scriptsize] {Training period};
\draw [thick,decorate,decoration={brace,amplitude=5pt}] (6,-.9) -- +(-1,0)
node [black,midway,font=\scriptsize, below=4pt] {Testing period};
\end{tikzpicture}
\end{document}
Best Answer
The timeline arrow is hard coded in the sty-file as
[|->]
. You can change it globally by setting>=|
but that means all your tikzpictures will have|
as the default arrow tip.As noted by Schweinebacke the
\tikzset
can be put inside{...}
which makes the changes local.