4

I have written the code for this figure, how can I add these two dashes to it enter image description here

\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 [input, name=input] {};
        
        \node [block, right=of input] (plant) {$controller$};
        
        
    \end{tikzpicture}
\end{document}
2
  • 2
    '\draw[dashed] ....;'
    – Black Mild
    Apr 13 at 15:25
  • 1
    (And posting your code would make answering even easier, i.e. more specific ...)
    – MS-SPO
    Apr 13 at 15:53

1 Answer 1

6

Here's a way to do it.

Especially when you are a beginner in Tikz I suggest to do it step-by-step, see my numbers in the comments, and move from imperfect to fine (enough).

Some remarks which go beyond my comments:

  • using absolute coordinates gives you more control as a beginner; later you may move to the positioning library or other tools
  • always start simple, e.g. \draw (A) -- (B); (straight), refine later, e.g. \draw (A) |- (B); (vertical, then horizontal connection)
  • use styles to make your code more readable
  • introduce intermediate points, e.g. relative +() or as new absolute ++() coordinate
  • Tikz uses the path concept, starting syntactically with \, ending with ; and doing whatever actions in between
  • that's why you can put node (without \ !) before the path is finished to place a label
  • using anchor is nice to change reference away from a nodes center
  • polar coordinates can be your friend, either as coordinate like (45:1), or around a nodes shape (A.north) == (A.90)

Good luck + look up these commands in the tikz-manual in parallel.

result

\documentclass[10pt,border=3mm,tikz]{standalone}
% ~~~ (4) replace arrow tip ~~~~~~~~~~
\usetikzlibrary{arrows.meta}

\begin{document}
 \begin{tikzpicture}[ % ~~~ (2) doing some style ~~~
    blk/.style={draw,minimum height=1cm,minimum width=3cm},
    LL/.style={line width=3pt, draw=blue!70!green!40},
    >={Triangle}, % ~~~ (4) replace arrow tip ~~~~~~~~~~
 ]
    % ~~~ (1) putting a node ~~~~~~~~
    \node[blk] (C) at (0,0) {controller};
    
    % ~~~ (3) drawing the blue line ~~~~~~
    \draw[->,LL]  (6,1.5) -| (C);
    
    % ~~~ (5) left indicator ~~~~~~~~~~~~
    \draw[dashed] (C.120) -- ++(100:3) -- +(-4,0) 
            node[anchor=south west] {distributed controller}; 

    % ~~~ (6) right indicator ~~~~~~~~~~~~
    \draw[dashed] (2,1.5) -- ++(45:2) -- +(4,0)
            node[anchor=south east] {communication topology}
            node[anchor=north east,pos=.6] {delay}
            ;   
 \end{tikzpicture}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .