![如何绘制一个条形图(一个高度非常小的填充矩形,就像“线”形状的节点)?](https://linux22.com/image/276324/%E5%A6%82%E4%BD%95%E7%BB%98%E5%88%B6%E4%B8%80%E4%B8%AA%E6%9D%A1%E5%BD%A2%E5%9B%BE%EF%BC%88%E4%B8%80%E4%B8%AA%E9%AB%98%E5%BA%A6%E9%9D%9E%E5%B8%B8%E5%B0%8F%E7%9A%84%E5%A1%AB%E5%85%85%E7%9F%A9%E5%BD%A2%EF%BC%8C%E5%B0%B1%E5%83%8F%E2%80%9C%E7%BA%BF%E2%80%9D%E5%BD%A2%E7%8A%B6%E7%9A%84%E8%8A%82%E7%82%B9%EF%BC%89%EF%BC%9F.png)
我现在对 Petri 网的印象是
问题:'条'(灰色)太高,尽管minimum height=0.1mm
(似乎没有任何效果)。是否可以将这些灰色矩形变得更薄?
代码是(不需要阅读全部内容,只需查看两条注释):
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,automata,positioning,calc,patterns,petri}
\begin{document}
\begin{tikzpicture}[node distance=1.3cm,>=stealth',bend angle=45,auto]
\tikzstyle{place}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=6mm]
\tikzstyle{red place}=[place,draw=red!75,fill=red!20]
\tikzstyle{transition}=[rectangle, % <------Can we make them thinner?
thick,
draw=black!75,
fill=black!25,
minimum height=0.1mm, %<------------------ this doesn't help
minimum width=8mm,
rounded corners]
\tikzstyle{every label}=[red]
\node [place,tokens=1] (start) {$start$};
\node [transition] (start_to_start_q0) [below left of=start] {};
\node [transition] (start_to_q0_ok) [below right of=start] {};
\node [place] (q0) [below of=start_to_start_q0] {$q_0$};
\node [place] (ok) [below of=start_to_q0_ok] {$ok$};
\node [place] (q) [below left of=q0] {$q$};
\node [transition] (from_q_ok) [below right of=q] {};
\node [place] (qsa) [below left of=from_q_ok] {$q_{a!!}$};
\node [place] (a) [right of=qsa] {$a$};
\node [transition] (from_qsa_a) [below right of=qsa] {};
\node [place] (p) [right of=a] {$p$};
\node [transition] (from_a_p) [below right of=a] {};
\node [place] (qend) [below of=from_qsa_a] {$q'$};
\node [place] (pra) [below of=from_a_p] {$p_{a??}$};
\node [transition] (from_ok_pra) [right of=pra] {};
\node [place] (pend) [right of=from_ok_pra] {$p'$};
\path (start_to_start_q0)
edge [pre,bend right] (start)
edge [post] (start)
edge [post] (q0);
\path (start_to_q0_ok)
edge [pre] (start)
edge [post] (q0)
edge [post] (ok);
\path (from_q_ok)
edge [pre] (q)
edge [pre] (ok)
edge [post] (qsa)
edge [post] (a);
\path (from_qsa_a)
edge [pre] (qsa)
edge [pre] (a)
edge [post] (qend)
edge [post] (ok);
\path (from_a_p)
edge [pre] (a)
edge [pre] (p)
edge [post] (pra)
edge [post] (a);
\path (from_ok_pra)
edge [pre] (ok)
edge [pre] (pra)
edge [post] (ok)
edge [post] (pend);
\end{tikzpicture}
\end{document}
答案1
节点inner sep
选项是节点填充,用于确保节点文本和节点边框之间的空间。通过将其设置为零,您可以根据minimum height
需要控制节点高度。
此代码:
\tikzstyle{transition}=[rectangle,
thick,
draw=black!75,
fill=black!25,
minimum height=1mm,
minimum width=8mm,
rounded corners,
inner sep=0]
节点高度为 1 毫米,但圆角现在看起来很奇怪。也许这是另一个问题。