
나는 이 그림을 플롯하고 싶고 이것이 내 코드와 결과입니다. 블록의 크기와 거리가 원본 그림과 동일하기를 원합니다. 또한 "네트워크"는 점선 안에 있어야 합니다.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,fit}
\usetikzlibrary{arrows,calc,positioning}
\usetikzlibrary{shapes,arrows,positioning,calc}
\begin{document}
\newlength\estilength
\settowidth\estilength{$estimator$}
\tikzset{
block/.style = {draw, fill=white, rectangle, minimum height=3em, minimum width=3em,text width=\estilength,align=center},
tmp/.style = {coordinate},
sum/.style= {draw, fill=white, circle, node distance=1cm},
input/.style = {coordinate},
output/.style= {coordinate},
pinstyle/.style = {pin edge={to-,thin,black}
},
point/.style = {draw, fill=black, circle, minimum size=0.8mm, node distance=1.5cm, inner sep=0pt},
dashed node/.style={draw,dashed,inner sep=7.5pt,rounded corners},
}%
\begin{tikzpicture}[auto, node distance=15mm,>=latex']
\node [block] (act) {$Actuator$};
\node [block, right=2 of act ] (plant) {Plant};
\node [block, right= 2 of plant] (c) {$sensor$};
\node [block, below=15mm of c] (delay) {$Delay$};
\node [block, below=30mmof plant] (control) {$controller$};
\node [block, below=15mm of act] (me) {$measur$};
\draw [->] (act) --(plant);
\draw [->] (plant) -- (c);
\draw [->] (c) -- (delay);
\draw [->] (delay) |- (control);
\draw [->] (control) -| (me);
\draw [->] (me) -- (act);
\node [dashed node,fit=(me)(delay),label=above:{network}] {};
\end{tikzpicture}
\end{document}
답변1
이와 같이?
해당 라벨은회로망실제로는 노드 중앙에 있으므로 레이블로 작성해야 합니다(아래 MWE 참조).
MWE에서는 노드 이름을 단축하고 chains
라이브러리를 추가하고 \tikzset{...}
이미지에 사용되는 스타일만 고려했습니다.
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
fit}
\begin{document}
\newlength\estilength
\settowidth\estilength{\emph{controller}}
\tikzset{
arr/.style = {-Latex, semithick},
every edge/.append style = {draw, arr},
FIT/.style args = {#1/#2}{draw, densely dashed, inner sep=1em,
label = {[font=\large]center:#1},
fit=#2,
},
N/.style = {draw, fill=white, align=center, font=\itshape,
minimum height=5ex, minimum width=\estilength,
text width=\pgfkeysvalueof{/pgf/minimum width}+2*\pgfkeysvalueof{/pgf/inner xsep},
},
P/.style = {N, font=\textrm\large, on chain},
}
\begin{tikzpicture}[auto,
node distance = 10mm and 15mm,
start chain = going right]
\begin{scope}[nodes={N, on chain, join=by arr}]
\node (act) {Actuator};
\node (plant) [P] {Plant};
\node (c) {sensor};
\end{scope}
\node (delay) [N, below=of c] {Delay};
\node (msr) [N, below=of act] {measure};
\node (cntrl) [N, below = of msr.south -| plant] {controller};
%
\node [FIT= network/(msr)(delay)] {};
%
\draw[arr] (msr) edge (act)
(c) to (delay);
\draw [arr] (delay) |- (cntrl);
\draw [arr] (cntrl) -| (msr);
\end{tikzpicture}
\end{document}
부록:
분명히 나는 첫 번째 이미지를 놓치고 MWE가 그것을 재현해야 한다고 요구합니다. 아래의 새로운 MWE는 다음을 가능하게 합니다.
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
fit}
\begin{document}
\newlength\estilength
\settowidth\estilength{\emph{controller}}
\tikzset{
arr/.style = {-Latex, semithick},
every edge/.append style = {draw, arr},
FIT/.style args = {#1/#2}{draw, densely dashed, inner sep=1em,
label = {[font=\large]center:#1},
fit=#2,
},
N/.style = {draw, semithick, align=center, font=\itshape,
minimum height=5ex, minimum width=#1,
text width=\pgfkeysvalueof{/pgf/minimum width}+2*\pgfkeysvalueof{/pgf/inner xsep},
},
N/.default = \estilength,
P/.style = {N, font=\textrm\large, on chain},
}
\begin{tikzpicture}[auto,
node distance = 10mm and 15mm,
start chain = going right]
\begin{scope}[nodes={N, on chain, join=by arr}]
\node (act) {Actuator};
\node (plant) [P] {Plant};
\node (c) {sensor};
\end{scope}
\node (delay) [N=2*\estilength, below=of c] {Actuation\\ Delay}; % here is adjusted width of node's shape
\node (msr) [N=2*\estilength, below=of act] {Measurement\\ Delay}; % here is adjusted width of node's shape
\node (cntrl) [N, below = of msr.south -| plant] {controller};
%
\node [FIT= network/(msr)(delay)] {};
%
\draw[arr] (msr) edge (act)
(c) to (delay);
\draw [arr] (delay) |- (cntrl);
\draw [arr] (cntrl) -| (msr);
\end{tikzpicture}
\end{document}