如何使用 tikz-pgf 创建具有锐利大边缘的垂直时间线?

如何使用 tikz-pgf 创建具有锐利大边缘的垂直时间线?

在此处输入图片描述

我想使用启动代码重新创建上述时间线,但我不知道如何编辑颜色,如何从下面的代码中删除呈现的左侧栏。

\documentclass[tikz, margin=3.141592mm]{standalone}
\usetikzlibrary{arrows.meta,
                chains,
                positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 1mm and 3mm,
  start chain = A going below,
   dot/.style = {circle, draw=white, very thick, fill=gray,
                 minimum size=3mm},
   box/.style = {rectangle, text width=62mm,
                 inner xsep=4mm, inner ysep=1mm,
                 font=\sffamily\small\linespread{0.84}\selectfont,
                 on chain},
                        ]
    \begin{scope}[every node/.append style={box}]
\node { From september 2010 to september 2013   \\      % A-1
        \textcolor{gray}{Industrial design}     \\
        Universidad Antonio de Nebrija, Madrid} ;
\node { From september 2010 to september 2013   \\
        \textcolor{gray}{Industrial design}     \\
        Universidad Antonio de Nebrija, Madrid} ;
\node { From september 2010 to september 2013   \\      % A-3
        \textcolor{gray}{Industrial design}     \\
        Universidad Antonio de Nebrija, Madrid} ;
    \end{scope}
\draw[very thick, gray, {Triangle[length=4pt)]}-{Circle[length=3pt]},
      shorten <=-3mm, shorten >=-3mm]           % <--- here is adjusted additional arrow's 
    (A-1.north west) -- (A-3.south west);
\foreach \i [ count=\j] in {2013,2010,2006}
    \node[dot,label=left:\i] at (A-\j.west) {};
    \end{tikzpicture}
\end{document}

答案1

您显示的代码分为三部分

第 1 部分是时间线右侧的文本

\documentclass[tikz, margin=3.141592mm]{standalone}
\usetikzlibrary{arrows.meta,
                chains,
                positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 1mm and 3mm,
  start chain = A going below,
   dot/.style = {circle, draw=white, very thick, fill=gray,
                 minimum size=3mm},
   box/.style = {rectangle, text width=62mm,
                 inner xsep=4mm, inner ysep=1mm,
                 font=\sffamily\small\linespread{0.84}\selectfont,
                 on chain},
                        ]
    \begin{scope}[every node/.append style={box}]
\node { From september 2010 to september 2013   \\      % A-1
        \textcolor{gray}{Industrial design}     \\
        Universidad Antonio de Nebrija, Madrid} ;
    \end{scope}
    \end{tikzpicture}
\end{document}

结果是

在此处输入图片描述

该节点自动命名为 A-1 - 您可以通过更改代码将其更改为 B、C 等

start chain = B going below,

类似地,节点 A-2、A-3 的剩余部分使用代码转换为时间线右侧的文本

    \begin{scope}[every node/.append style={box}]
\node { From september 2010 to september 2013   \\      % A-1
        \textcolor{gray}{Industrial design}     \\
        Universidad Antonio de Nebrija, Madrid} ;
\node { From september 2010 to september 2013   \\
        \textcolor{gray}{Industrial design}     \\
        Universidad Antonio de Nebrija, Madrid} ;
\node { From september 2010 to september 2013   \\      % A-3
        \textcolor{gray}{Industrial design}     \\
        Universidad Antonio de Nebrija, Madrid} ;
    \end{scope}

结果是

在此处输入图片描述

第二部分代码绘制垂直箭头

\draw[very thick, gray, {Triangle[length=4pt)]}-{Circle[length=3pt]},
      shorten <=-3mm, shorten >=-3mm]           % <--- here is adjusted additional arrow's 
    (A-1.north west) -- (A-3.south west);

结果是

在此处输入图片描述

第三部分 借助代码绘制三个圆圈

 \foreach \i [ count=\j] in {2013,2010,2006}
    \node[dot,label=left:\i] at (A-\j.west) {};

这三个圆圈是该法典执行部分的结果

[ count=\j] in {2013,2010,2006}

然后从代码左侧给这三个圆圈贴上标签

\node[dot,label=left:\i] at (A-\j.west) {};

其中\i is generated as 2006, 2010 and 2013

并且标签是在label=left:\i那时生成的left of 2006, 2010 and 2013

三个圆圈位于(A-\j.west)转换为A-1.west, A-2.west and A-3.west

因此整个代码的结果在时间轴上

在此处输入图片描述

改变圆圈样式是通过

 dot/.style = {circle, draw=white, very thick, fill=gray,
                 minimum size=3mm},

例如,如果你省略 white indraw=white并简单地写

 dot/.style = {circle, draw=blue, very thick, fill=gray,
                 minimum size=3mm},

这导致

在此处输入图片描述

或更改fill=gray

 dot/.style = {circle, draw=blue, very thick, fill=blue!20,
                 minimum size=3mm},

这导致

在此处输入图片描述

希望这有助于明确下一步该怎么做

相关内容