我目前尝试可视化生物识别系统的组和子组。我想摆脱陈旧乏味的箭头,并想使用类似缩放或细节视图的效果(见图片;深蓝色 -> 浅蓝色;颜色可以替换),但我缺乏 Tikz/PGF 方面的技能来可视化这种效果。我设法得到了一些盒子,但是,我宁愿不把它写进我的论文里。
有什么我可以学习的提示或资源吗?
根据要求:我的当前区块
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[remember picture,
application/.style={fill=black!10,rounded corners,inner sep=20pt},
biometric/.style={rounded corners,draw=blue!50,fill=blue!20,thick,inner sep=3pt},
detail/.style={fill=blue!10,draw=blue,rounded corners,inner sep=15pt},
subdetail/.style={draw=red!75,fill=red!20,rounded corners,inner sep=5pt},
empty subdetail/.style={draw=blue!10,rounded corners,inner sep=5pt}
]
\node[application] (application) {
\begin{tikzpicture}
\node[biometric] (image) {
\begin{tikzpicture}
\node (image-head) {Data Capture Subsystem};
\node [detail,draw=blue,below=0.1cm of image-head] (detail) {
\begin{tikzpicture}
\end{tikzpicture}
};
\end{tikzpicture}
};
\node[biometric,below=0.1cm of image] (signal) {
\begin{tikzpicture}
\node (signal-head) {Signal Processing Subsystem};
\node [detail,draw=blue,below=0.1cm of signal-head] (detail) {
\begin{tikzpicture}
\node [subdetail,draw=blue] (detail1) {Quality Control};
\node [subdetail,draw=blue,below=0.1cm of detail1] (detail2) {Pre-Processing};
\node [subdetail,draw=blue,below=0.1cm of detail2] (detail3) {Feature Extraction};
\node [subdetail,draw=blue,below=0.1cm of detail3] (detail4) {Post-Processing};
\end{tikzpicture}
};
\end{tikzpicture}
};
\node[biometric,below=0.1cm of signal] (storage) {
\begin{tikzpicture}
\node (storage-head) {Data Storage Subsystem};
\node [detail,draw=blue,below=0.1cm of storage-head] (detail) {
\begin{tikzpicture}
\end{tikzpicture}
};
\end{tikzpicture}
};
\node[biometric,below=0.1cm of storage] (comp) {
\begin{tikzpicture}
\node (comp-head) {Comparsion Subsystem};
\node [detail,draw=blue,below=0.1cm of comp-head] (detail) {
\begin{tikzpicture}
\end{tikzpicture}
};
\end{tikzpicture}
};
\node[biometric,below=0.1cm of comp] (dec) {
\begin{tikzpicture}
\node (dec-head) {Decision Subsystem};
\node [detail,draw=blue,below=0.1cm of dec-head] (detail) {
\begin{tikzpicture}
\end{tikzpicture}
};
\end{tikzpicture}
};
\end{tikzpicture}
};
\node [black,below] at (application.north) {Biometric Subsystem};
\end{tikzpicture}
\end{document}
答案1
一般情况下tikzpicture
不建议使用嵌套环境,例如此评论,而且它也并不总是有效。
但在本例中你不需要它,下面的代码展示了一种在 中执行类似操作的可能方法tikzpicture
。左右之间的连接可能需要改进。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
positioning,
matrix,
chains,
backgrounds,
fit
}
\begin{document}
\begin{tikzpicture}[
application/.style={
rounded corners,
fill=black!10,
inner sep=20pt
},
biometric/.style={
rounded corners,
draw=blue!50,
fill=blue!20,
thick,
inner sep=3pt,
minimum width=5cm,
minimum height=1cm
},
detail/.style={
rounded corners,
fill=blue!10,
draw=blue,
inner sep=10pt,
outer sep=0pt% added
},
subdetail/.style={
rounded corners,
draw=red!75,
fill=red!20,
inner sep=5pt,
minimum width=4cm
},
empty subdetail/.style={
rounded corners,
draw=blue!10,
inner sep=5pt
}
]
\begin{scope}[
% start a new chain called subsys that goes downwards
start chain=subsys going below,
% set the style for all the nodes in the scope
every node/.append style={biometric,on chain,join},
% define how connections between nodes on the chain are drawn
every join/.style={-latex},
% set distance between nodes
node distance=3mm
]
\node {Data Capture Subsystem};
\node {Signal Processing Subsystem};
\node {Data Storage Subsystem};
\node {Comparison Subsystem};
\node {Decision Subsystem};
\end{scope}
\matrix [
% position the top left corner of the matrix 2cm right of the
% top right corner of the first node on the chain
% the nodes in the chain are automatically named subsys-1, subsys-2 etc.
right=2cm of subsys-1.north east,
anchor=north west,
% set the style of the matrix itself
detail,
% make each cell a node, so we don't have to write \node [style] {.,,}; in every cell
matrix of nodes,
% set distance between rows
row sep=3mm,
% set the style of the nodes in the matrix
nodes=subdetail
] (m)
{
Quality control \\
Pre-Processing \\
Feature Extraction \\
Post-Processing \\ % even the last row has to be ended with \\
};
% draw arrows between each element in matrix
% the matrix name is m, so the nodes are automatically named
% m-<row number>-<column number>
% hence \draw (m-1-1) -- (m-2-1) draws a line from the first to the second node
% here I use a loop to draw the arrows
\foreach [remember=\x as \lastx (initially 1)] \x in {2,3,4}
\draw [-stealth] (m-\lastx-1) -- (m-\x-1);
% draw the connection, can be improved
\draw [blue] (subsys-1.east) to[bend right=2] ([yshift=-5pt]m.north west);
\draw [blue] (subsys-1.east) to[out=-15,in=90] ([yshift=7pt]m.south west);
% fill the background
\begin{scope}[on background layer]
\node [application,fit=(current bounding box)] {};
\end{scope}
\end{tikzpicture}
\end{document}
所有连锁店
您也可以不使用 来执行此操作\matrix
。这样,您可以自动获得子细节之间的连接,与左侧的节点相同,但您需要额外的步骤来绘制子细节后面的框。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
positioning,
matrix,
chains,
backgrounds,
fit
}
\begin{document}
\begin{tikzpicture}[
application/.style={
rounded corners,
fill=black!10,
inner sep=20pt
},
biometric/.style={
rounded corners,
draw=blue!50,
fill=blue!20,
thick,
inner sep=3pt,
minimum width=5cm,
minimum height=1cm
},
detail/.style={
rounded corners,
fill=blue!10,
draw=blue,
inner sep=10pt,
outer sep=0pt% added
},
subdetail/.style={
rounded corners,
draw=red!75,
fill=red!20,
inner sep=5pt,
minimum width=4cm
},
empty subdetail/.style={
rounded corners,
draw=blue!10,
inner sep=5pt
}
]
\begin{scope}[
% start a new chain called subsys that goes downwards
start chain=subsys going below,
% set the style for all the nodes in the scope
every node/.append style={biometric,on chain,join},
% define how connections between nodes on the chain are drawn
every join/.style={-latex},
% set distance between nodes
node distance=3mm
]
\node {Data Capture Subsystem};
\node {Signal Processing Subsystem};
\node {Data Storage Subsystem};
\node {Comparison Subsystem};
\node {Decision Subsystem};
\end{scope}
\begin{scope}[
% start a new chain called details that goes downwards
start chain=details going below,
% set the style for all the nodes in the scope
every node/.append style={subdetail,on chain,join},
% define how connections between nodes on the chain are drawn
every join/.style={-latex},
% set distance between nodes
node distance=3mm
]
\node [right=2cm of subsys-1] {Quality control};
\node {Pre-Processing};
\node {Feature Extraction};
\node {Post-Processing};
\end{scope}
\begin{scope}[on background layer]
% fill the background
\node [application,fit=(current bounding box)] {};
% make the detail box
\node [detail,fit=(details-1)(details-4)] (m) {};
\end{scope}
% draw the connection, can be improved
\draw [blue] (subsys-1.east) to[bend right=2] ([yshift=-5pt]m.north west);
\draw [blue] (subsys-1.east) to[out=-15,in=90] ([yshift=7pt]m.south west);
\end{tikzpicture}
\end{document}