我想改善下图的外观。
\documentclass{standalone}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,shapes.multipart}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{every fit/.append style = text badly centered} % removes underfull warnings while using fit
\tikzset{%
default/.style = {draw, thick, align = center, shape = rectangle, minimum height = 10mm, minimum width = 20mm, text width = 15mm},
back1/.style = {draw = none, align = center, shape = rectangle, minimum height = 15mm, minimum width = 25mm, inner sep = 2mm},
back2/.style = {back1, draw, dashed, thick, minimum width = 30mm, inner sep = 4mm},
terminal/.style = {draw, thick, align = center, shape = circle, text width = 10mm},
}
\begin{document}
\begin{tikzpicture}
%
\node [default] (AAA) {AAA};
\node [default] (PPP) [right = of AAA] {NNN};
\node [default] (ZZZ) [right = of PPP] {ZZZ};
\draw [thick] (AAA) -- (PPP) -- (ZZZ);
\begin{pgfonlayer}{background}
\node [back1, fit = (AAA) (PPP) (ZZZ) ] (FFF) {};
\end{pgfonlayer}
\node [rotate = 90, anchor = south] at (FFF.west) {\textbf{FFF}};
%
\node [default] (QQQ1) at ($(AAA)!0.5!(PPP)$) [yshift = -20mm] {CCC};
\node [default] (QQQ2) at ($(PPP)!0.5!(ZZZ)$) [yshift = -20mm] {CCC};
\draw node [left = 1em of QQQ1] (DOTS1) {\dots};
\draw node [right = 1em of QQQ2] (DOTS2) {\dots};
\draw [thick] (QQQ1) -- (QQQ2);
\begin{pgfonlayer}{background}
\node [back1, fit = (DOTS1) (QQQ1) (QQQ2) (DOTS2) ] (DDD) {};
\end{pgfonlayer}
\node [rotate = 90, anchor = south] at (DDD.west) {\textbf{III}};
\begin{pgfonlayer}{background}
\node [back2, fit = (FFF) (DDD) ] (HHH) {};
\end{pgfonlayer}
%\node [rotate = 90, anchor = south] at (HHH.west) {\textbf{Network}};
%
\node [terminal] (BB1) at (AAA.west) [yshift = -60mm, xshift = 5mm] {BB};
\node [terminal] (BB2) [right = of BB1] {BB};
%\node [terminal] (BB2) at (BB1.east) [xshift = 15mm] {BB};
\draw[<->, thick] (BB1) -- (BB2);
%
\node [terminal] (BB4) at (ZZZ.east) [yshift = -60mm, xshift = -5mm] {BB};
\node [terminal] (BB3) [left = of BB4] {BB};
%\path [draw, thick, out = 295, in = 90] (HHH) edge (BB3);
%\path [draw, thick, out = 325, in = 90] (HHH) edge (BB4);
\begin{pgfonlayer}{background}
\node [back2, fit = (BB1) (BB2) ] (CCC) {};
\node [back2, fit = (BB3) (BB4) ] (DDD) {};
\end{pgfonlayer}
\draw[<->, thick] (BB3) .. controls +(up:40mm) and +(up:40mm) .. (BB4);
\node [anchor = north] at (CCC.south) {\textbf{CCC Mode}};
\node [anchor = north] at (DDD.south) {\textbf{XXX Mode}};
\draw [<->, thick] (HHH.south) -- (CCC.north) node [midway, left, align = center] {Assistance};
\end{tikzpicture}
\end{document}
即,
- 改进布局,使节点距离更加灵活:垂直和水平;
- 文字“III”和“FFF”应左对齐
- 垂直线(标有“援助”字样),将其放直。
答案1
- 你只需要
\xnodedist
改变\ynodedist
- 用 来定位它们
below=
。我使用 是rotatebox
因为有奇怪的交互。 - 您可以使用“通过 p 的垂直线与通过 q 的水平线的交点。”符号(参见 PGF 手册,第 32 页)
代码
\documentclass[tikz,birder=2mm]{standalone}
\usetikzlibrary{%
shapes.geometric,%
shapes.multipart,%
positioning,%
calc,%
fit,%
backgrounds,%
decorations.pathmorphing}
\usepackage{lmodern}
\usepackage{mathtools}
\tikzset{every fit/.append style = text badly centered} % removes underfull warnings while using fit
\tikzset{%
default/.style = {draw, thick, align = center, shape = rectangle, minimum height = 10mm, minimum width = 20mm, text width = 15mm},
back1/.style = {draw = none, align = center, shape = rectangle, minimum height = 15mm, minimum width = 25mm, inner sep = 2mm},
back2/.style = {back1, draw, dashed, thick, minimum width = 30mm, inner sep = 4mm},
terminal/.style = {draw, thick, align = center, shape = circle, text width = 10mm},
}
\pgfmathsetmacro{\xnodedist}{2}% in cm
\pgfmathsetmacro{\ynodedist}{1.5}% in cm
\begin{document}
\begin{tikzpicture}
\node [default] (AAA) {AAA};
\node [default] (PPP) [right=\xnodedist of AAA] {NNN};
\node [default] (ZZZ) [right=\xnodedist of PPP] {ZZZ};
\node (FFF_label) [left=0.2*\xnodedist of AAA.west] {\rotatebox{90}{\textbf{FFF}}};
\draw [thick] (AAA) -- (PPP) -- (ZZZ);
\node [back1, fit=(AAA)(PPP)(ZZZ)(FFF_label)] (FFF) {};
\node [default] (QQQ1) [below=\ynodedist of $(AAA)!0.5!(PPP)$] {CCC};
\node [default] (QQQ2) [right=\xnodedist of QQQ1] {CCC};
\node (III_label) [below=\ynodedist of FFF_label.center] {\rotatebox{90}{\textbf{III}}};
\node [left=1em of QQQ1] (DOTS1) {\dots};
\node [right=1em of QQQ2] (DOTS2) {\dots};
\draw [thick] (QQQ1) -- (QQQ2);
\node [back1, fit= (DOTS1)(QQQ1)(QQQ2)(DOTS2)(III_label)] (DDD) {};
\node [back2, fit= (FFF)(DDD)] (HHH) {};
\node [terminal] (BB1) [below=1.5*\ynodedist of HHH.south west, xshift=0.5*\xnodedist*1cm] {BB};
\node [terminal] (BB2) [right=0.5*\xnodedist of BB1] {BB};
\draw[<->, thick] (BB1) -- (BB2);
\node [terminal] (BB4) [below=1.5*\ynodedist of HHH.south east, xshift=-0.5*\xnodedist*1cm] {BB};
\node [terminal] (BB3) [left=0.5*\xnodedist of BB4] {BB};
\node [back2, fit = (BB1) (BB2) ] (CCC) {};
\node [back2, fit = (BB3) (BB4) ] (DDD) {};
\draw[<->, thick] (BB3) to[out=90,in=180] ($(DDD.north |- HHH.south)+(0,0.3)$) to[out=0,in=90] (BB4);
\node [below] at (CCC.south) {\textbf{CCC Mode}};
\node [below] at (DDD.south) {\textbf{XXX Mode}};
\draw [<->, thick] (CCC.north) -- (CCC.north |- HHH.south) node [midway, left, align = center] {Assistance};
\end{tikzpicture}
\end{document}