简单图表的可视化后端

简单图表的可视化后端

有人可以推荐一种将这种图表编码成 TeX 文档的解决方案吗?

简单图表示例

背景:为了寻找进一步的方法使我的论文中的所有内容可复制或至少以开放格式进行交流,我试图停止使用 OmniGraffle 来制作像上面这样的简单图表,这些图表在社会学、政治学和其他学科中很常见。

来自上一个问题, 我明白那个Graphviz图形可能适合,但我不明白它们如何使我的图表与我的 TeX 文档更加集成。

对我来说最好的办法可能是了解如何复制这些图表蒂克兹,但我不确定这是否会轻易实现,因为我无法找到有关该主题的教程(尝试使用 TikZ 将交换图调整为那种图表效果不佳)。

答案1

绘制此类图表的一种方法是使用节点定位。这是一个您可以尝试的版本。

\documentclass{minimal}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}


\begin{document}

\begin{tikzpicture}[every node/.style={align=center,minimum width=4cm,minimum height=2cm,rectangle,outer sep=0pt},>=latex,
  decoration={
    markings,%  switch on markings
    mark=at position 0.25  with {\draw (-4pt,-4pt) -- (4pt,4pt);\draw (4pt,-4pt) -- (-4pt,4pt);}}
    ]


\node (empty) {};
\node[below=of empty] (mech-1) {mechanism\\descriptor};
\node[below=of mech-1] (mech-2) {mechanism\\descriptor};

\node[right=of empty] (event) {\textbf{event}\\caption};

\node[draw,right=of mech-1] (process-1-1) {\textbf{process}\\caption};
\node[draw,right=of process-1-1] (process-1-2) {\textbf{process}\\caption};

\node[draw,right=3cm of mech-2] (process-2-1) {\textbf{intermediate process}};
\node[draw,right=of process-2-1] (process-2-2) {\textbf{intermediate process}};

\node[below=of process-2-1] (failure) {\textbf{failure}};
\node[below=of process-2-2] (success) {\textbf{success}};

\draw[->] (event) -- (process-1-1);
\draw[->] (process-1-1.south) -- (process-2-1.north);
\draw[->] (process-2-1.north) -- (process-1-2.south);
\draw[->] (process-1-2.south) -- (process-2-2.north);

\draw[postaction={decorate}] (process-2-1) -- (failure);
\draw[->] (process-2-2) -- (success);

\end{tikzpicture}

\end{document}

结果是

在此处输入图片描述

答案2

第 3 章pgf 手册(包括 tikz)是一个教程,它使用的示例看起来适用于上面的图表。还有一堆例子这里您可以从“链”和“节点定位”部分中的示例开始着手,它们看起来适用于上面的示例。

答案3

下面是另一个结合了 Frédérik 对该positioning库的使用和 Greg 对该chains库与其他几个库一起使用的建议(以纯格式):

\font\ss=cmss9
\font\ssbf=cmssbx10 at 9pt
\font\ssit=cmssi9
\let\tenbf\ssbf
\let\tenit\ssit
\input tikz
\usetikzlibrary{
  chains, % for the "start chain", "on chain", and "join" [manual section 28, p. 284]
  arrows, % for the ">=triangle 45" [manual section 23, p. 256-]
  positioning, % for the "left=<optional dimen> of ...",
               % and "below left=<optional dimen(s)> of ..."
               % [manual section 5.2, p. 62-]
  decorations.markings, % for the "X" on a join [manual p. 327-]
  shapes.multipart % for the "rectangle split" styles [manual p. 450-453]
  }
\tikzpicture[
    font=\ss,
    node distance=1.5cm and -1cm, % the y distance and x distance of nodes
    % ^the x distance is set to a negative value to reserve space
    every node/.style={minimum width=3cm,align=center},
    every on chain/.style=join,
    every join/.style={->,thick,>=triangle 45},
    mynode/.style={
      on chain=going #1,
      % ^you can give parameters to your styles, so that for example:
      % node[mynode=below] expands to: node[on chain=going below]
      inner xsep=1em,
      rectangle split,rectangle split parts=2,
      rectangle split ignore empty parts=true,
      rectangle split draw splits=false,
      every text node part/.style={font=\bf}},
    myfail/.style={thick,-,postaction={decorate,decoration={markings,
      % I have a feeling this could be accomplished more easily
      mark=at position .25 with { \draw (-3pt,-3pt) -- (3pt,3pt)
        (3pt,-3pt) -- (-3pt,3pt); }}}}
  ]

  \def\npt{\nodepart{two}} % just a local definition to save typing

  \draw[start chain]
    node[mynode] {event\npt caption}
    node[draw,mynode=below] (proc-1) {process\npt caption}
    node[draw,mynode=below right] {intermediary process}
    {[start branch,every join/.style=myfail]
      node[mynode=below] {failure\npt caption}}
    node[draw,mynode=above right] {process\npt caption}
    node[draw,mynode=below right] {intermediary process}
    node[mynode=below] {success\npt caption};

  \draw[every node/.append style={align=left,font=\it}]
    node[left=1cm of proc-1] (desc-1) {mechanism\\descriptor}
    % ^without the "1cm", the node would've been -1cm left of proc-1
    % because of the "node distance" definition for the whole tikzpicture
    node[below=of desc-1] {mechanism\\descriptor};
\endtikzpicture
\bye

好像:
在此处输入图片描述

相关内容