如何绘制树状时间线图?

如何绘制树状时间线图?

我正在尝试用 Tex 绘制附图(附件来自 Microsoft Word)。很高兴能做一些调整,但它需要看起来像这样。非常感谢! 在此处输入图片描述

编辑:您能否给我一个好的教程链接,以便我使用您认为最合适的工具,知道我想要绘制什么图表?

答案1

正如所说,tikzpgf会很好地工作。您将找到文档这里。我建议你开始阅读有关节点的文章。例如从

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning} % Necessary to use right=5cm of A
\begin{document}
\tikz{
  \node (A) [rectangle,draw] {Text of A};
  \node (B) [rectangle,draw,right=5cm of A] {Text of B} edge (A.east);
}
\end{document}

看看它产生了什么并进行调整...

答案2

如果你可以使用lualatex来处理你的文档,那么另一种选择luamplib元帖子我用它来绘制你图表的各部分的草图。

在此处输入图片描述

“以编程方式”制作此类图表的好处是,您可以将其绘制为图形,这样,例如,箭头现在是以年份为尺度的 x 轴,并且方框位于“正确”的位置。

我认为luamplib它现在已经相当成熟,速度很快,而且(我希望你能从示例中看到)它与 LaTeX 集成得很好。但我还不确定我是否会推荐它作为初学者工具;(a)因为 Metapost 提供的优秀教程材料还没有真正涵盖将其用作 LuaLatex 的一部分,并且(b)调试环境仍然很糟糕。

\documentclass[border=5mm]{standalone}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
vardef census_box(expr yy) = 
  save box; path box;
  box = unitsquare shifted (-1/2,-1/2) xscaled 42 yscaled 28  
        shifted 28 up;
  image(
    draw box withpen pencircle scaled 1.2;
    draw point 0.5 of box -- origin;
    label("\textbf{" & decimal yy & "}", center box + 5up);
    label("Census", center box + 5 down);
  ) shifted ((yy-alpha)*u,0)
enddef;
vardef rounds_box(expr dx, dy, yy, rtext, rnumbers) = 
  save box; path box;
  box = (superellipse(5/8 right, 1/2 up, 5/8 left, 1/2 down, 0.76)) xscaled 42 yscaled 38  
         shifted 38 down
         shifted (dx,dy);
  image(
    draw box; 
    draw point 2 of box {up} .. {up} origin;
    label("\textbf{" & decimal yy & "}", center box + 10 up);
    label(rtext, center box);
    label(rnumbers, center box + 10 down);
  ) shifted ((yy-alpha)*u,0)
enddef;

beginfig(1);
alpha = 1978;
omega = 2015;
span  = omega-alpha;
size  = 12cm;
u = size/span;

drawarrow origin -- right scaled size withpen pencircle scaled 1;

draw census_box(1982);
draw census_box(1990);
draw census_box(2001);
draw census_box(2010);

draw rounds_box(-12,  0, 1985, "Rounds","I, II");
draw rounds_box(  0,-40, 1987, "Rounds","III, IV, V");
draw rounds_box( 21,  0, 1988, "Round", "VI");
draw rounds_box(  0,  0, 1997, "Rounds", "VII, VIII");
draw rounds_box( 20,  0, 2001, "\textit{Round}", "\textit{IX}");

endfig;
\end{mplibcode}
\end{document}

用 编译lualatex

答案3

这是我的解决方案

\begin{figure}[H]
\center
%Timeline
\begin{tikzpicture} [
catg/.style={draw,dashed, minimum height=2em},
thick/.style=      {line width=0.8pt}
]

%line
\draw [thick][arrows={->[scale=2]}] (0,0) -- (15,0) ;
\draw [thick,dashed] (0.5,0) -- (0.5,-2.53);
\draw [thick](1,0) -- (1,0.3);
\draw [thick](5,0) -- (5,0.3);
\draw [thick](11,0) -- (11,0.3);
\draw [thick](14,0) -- (14,0.3);
\draw [thick] (3.5,0) -- (3.5,-0.5); % 1987
\draw [thick] (8,0) -- (8,-0.5); % 1997
\draw [thick] (11,0) -- (11,-0.5); % 2001
\draw [thick,dashed] (8,-2.1) -- (8,-2.53); 
\draw [thick,dashed] (3.5,-2.1) -- (3.5,-2.53); 

%census
\node [text width=1.5cm, align=center] at (1, 0.8)  { 1982  Census};
\node [text width=1.5cm, align=center] at (5, 0.8)  { 1990  Census};
\node [text width=1.5cm, align=center] at (11, 0.8)  { 2001  Census};
\node [text width=1.5cm, align=center] at (14, 0.8)  { 2010  Census};

%rounds
\node [text width=2.5cm, align=center] at (3.5, -1.3) [rectangle,draw,thick] { 1985-1987\\ Rounds I - VI};
\node [text width=1.8cm, align=center] at (8, -1.3) [rectangle,draw,thick] { 1997\\ Rounds VII, VIII};
\node [text width=1.4cm, align=center] at (11, -1.3) [rectangle,draw,thick] { 2001\\ \itshape Round IX};

%category
\node [catg] at (0.5, -3) (Pre) [rectangle,draw,thick] {Pre-Round};
\node [catg] at (3.5, -3) (A) [rectangle,draw,thick] {Part A} ;
\node [catg] at (8, -3) (B) [rectangle,draw,thick] {Part B} ;

\end{tikzpicture}
\caption{Timing of Bidding Rounds and Censuses}
\label{fig:speciation}\end{figure}

相关内容