使用此代码,
\begin{tikzpicture}
\draw[line width=1pt] (0,0) -- (12,0)node[right=4mm]{(periods)};
\foreach \x/\y in {18000/0,19080/1,20224.80/2,21438.29/3}%
{
\draw[line width=1pt] (4*\y,-2mm) node[below] {\y} -- ++(0,4mm) node[above] {\$ \num{\x}};
}
\draw[-latex] (2,-7mm) -- +(0,-10mm)node[below]{\$ \textbf{18,000}*0.06 = \$1,080};
\draw[-latex] (6,-7mm) -- +(0,-20mm)node[below]{\$ \textbf{19,080}*0.06 = \$1,144.80};
\draw[-latex] (10,-7mm) -- +(0,-10mm)node[below]{\$ \textbf{20224.80}*0.06 = \$1,213.49};
\end{tikzpicture}
但是,我想将这个年度复利转换为半年复利,总共收取 6 个利息,分别在 0 和 1/2、1/2 和 1、...、2 1/2 和 3 之间,通过将每个部分分成两部分显示在线下。我仍然希望在每年年底显示金额,因此时间线上方的金额应为:$18,000、$19,096.20、$20,259.16、$21,492.94。
我怎样才能获得这样的一条线?
答案1
最好将利息对齐到左侧,如图所示,这样看起来更整洁——现在只需在左侧交叉即可添加季度利息
\documentclass[tikz, margin=3mm]{standalone}
\usepackage{siunitx}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}
\draw[line width=1pt] (0,0)node(a){} -- (12,0)node(b){}[right=4mm];
\foreach \x/\y in {18000/0,19000/1,20000/2,21000/3}%
{
\draw[line width=1pt] (4*\y,-2mm) node[below] {\y} -- ++(0,4mm) node[above] {\$ \num{\x}};
\node [draw]at(-0.5cm,-2cm)(p){\$ {18,000}*0.06 = \$1,080};
\node [draw,below=of p.west,anchor=west](q){\$ {19,080}*0.06 = \$1,144.80};
\node [draw,below=of q.west,anchor=west](r){\$ {20224.80}*0.06 = \$1,213.49};
\draw[-latex] ($(a)!0.16!(b)$)node[below,yshift=-12pt,fill=white]{0.5} |-(p);
\draw[-latex] ($(a)!0.48!(b)$)node[below,yshift=-12pt,fill=white]{1.5} |-(q);
\draw[-latex] ($(a)!0.84!(b)$)node[below,yshift=-12pt,fill=white]{2.5} |-(r);
}
\end{tikzpicture}
\end{document}
编辑---季度利息
\documentclass[tikz, margin=3mm]{standalone}
\usepackage{siunitx}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}
\draw[line width=1pt] (0,0)node(a){} -- (12,0)node(b){}[right=4mm];
\foreach \x/\y in {18000/0,19000/1,20000/2,21000/3}%
{
\draw[line width=1pt] (4*\y,-2mm) node[below] {\y} -- ++(0,4mm) node[above] {\$ \num{\x}};
\node [draw]at(-0.5cm,-2cm)(p){\$ {18,000}*0.06 = \$1,080};
\node [draw,below=of p.west,anchor=west](q){\$ {19,080}*0.06 = \$1,144.80};
\node [draw,below=of q.west,anchor=west](r){\$ {20224.80}*0.06 = \$1,213.49};
\node [draw,below=of r.west,anchor=west](s){\$ {quarterly interest}*0.06 = \$X};
\draw[-latex] ($(a)!0.16!(b)$)node[below,yshift=-12pt,fill=white]{0.5} |-(p);
\draw[-latex] ($(a)!0.48!(b)$)node[below,yshift=-12pt,fill=white]{1.5} |-(q);
\draw[-latex] ($(a)!0.84!(b)$)node[below,yshift=-12pt,fill=white]{2.5} |-(r);
\draw[-latex] ($(a)!0.92!(b)$)node[below,yshift=-20pt,fill=white]{2.75} |-(s);
}
\end{tikzpicture}
\end{document}