Reputation: 153
I would like to illustrate graphically a bandwidth segmentizer. To do so, I would like to represent the following diagram in TikZ
So far, I have the following LaTeX code
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage{amsmath, amssymb, mathtools}
\usepackage{physics}
\newcounter{cnt}\setcounter{cnt}{0}
\begin{document}
\tikzset{str_to_vec/.style = {rectangle, draw, minimum width=3cm, text centered}}
\tikzset{modulus2/.style = {rectangle, draw, text centered}}
\tikzset{thresh/.style = {rectangle, draw, text centered}}
\tikzset{dottedline/.style = {ultra thick, loosely dotted,shorten >=1mm, shorten <=1mm}}
\begin{tikzpicture}[>=latex]
\node[rectangle, draw] (RX) at (0, 0) {Rx};
\node[
rectangle,
draw,
minimum height=3cm,
text width=1.8cm,
text centered
]
(PFB_CHANNELIZER) at ($(RX) + (3, 0)$)
{PFB\\ Channelizer};
\draw[->]
(RX)
--
(
$(PFB_CHANNELIZER.north west)
!0.5!
(PFB_CHANNELIZER.south west)$
);
\foreach \i in {0.15, 0.35}
{
\draw[->]
(
$(PFB_CHANNELIZER.north east)
!\i!
(PFB_CHANNELIZER.south east)$
)
coordinate (PFB_\thecnt)
to
++(1.5, 0)
coordinate (STR_TO_VEC_\thecnt)
node[str_to_vec, anchor=west] {stream to vector};
\draw[->]
(STR_TO_VEC_\thecnt.east)
to
++(5, 0)
coordinate (MODULUS2_\thecnt)
node[modulus2, anchor=west] {$\norm{\cdot}^2$};
\draw[->]
(MODULUS2_\thecnt.east)
to
++(5, 0)
coordinate (THRESHOLD_\thecnt)
node[thresh, anchor=west] {threshold};
\stepcounter{cnt}
}
\draw[->]
(
$(PFB_CHANNELIZER.north east)
!0.85!
(PFB_CHANNELIZER.south east)$
)
coordinate (PFB_3)
to
++(1.5, 0)
coordinate (STR_TO_VEC_3)
node[str_to_vec, anchor=west] {stream to vector};
\draw[->]
(STR_TO_VEC_3.east)
to
++(5, 0)
coordinate (MODULUS2_3)
node[modulus2, anchor=west] {$\norm{\cdot}^2$};
\draw[->]
(MODULUS2_3.east)
to
++(5, 0)
coordinate (THRESHOLD_3)
node[thresh, anchor=west] {threshold};
\draw[dottedline]
(STR_TO_VEC_1.south)
--
(STR_TO_VEC_3.north);
\draw[dottedline]
(MODULUS2_1.south)
--
(MODULUS2_3.north);
\end{tikzpicture}
\end{document}
which produces a strange output
(probably because of the anchor=west
) options, and I do not know how to do without these. Can someone help me out ?
Thank you and have a nice day, Alex
Upvotes: 1
Views: 182
Reputation: 153
Thanks to the answer of @samcarter_is_at_topanswers.xyz, the code delivering good results reads
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage{amsmath, amssymb, mathtools}
\usepackage{physics}
\newcounter{cnt}\setcounter{cnt}{0}
\begin{document}
\tikzset{str_to_vec/.style = {rectangle, draw, minimum width=3cm, text centered}}
\tikzset{modulus2/.style = {rectangle, draw, text centered}}
\tikzset{thresh/.style = {rectangle, draw, text centered}}
\tikzset{dottedline/.style = {ultra thick, loosely dotted,shorten >=1mm, shorten <=1mm}}
\begin{tikzpicture}[>=latex]
%===========
% NODES
%===========
\node[rectangle, draw] (RX) at (0, 0) {Rx};
\node[
rectangle,
draw,
minimum height=3cm,
text width=1.8cm,
text centered
]
(PFB_CHANNELIZER) at ($(RX) + (3, 0)$)
{PFB\\ Channelizer};
% %=================
% % CONNECTIONS
% %=================
\draw[->]
(RX)
--
(
$(PFB_CHANNELIZER.north west)
!0.5!
(PFB_CHANNELIZER.south west)$
);
\foreach \i in {0.15, 0.35}
{
\draw[->]
(
$(PFB_CHANNELIZER.north east)
!\i!
(PFB_CHANNELIZER.south east)$
)
coordinate (PFB_\thecnt)
to
++(1.5, 0)
node[str_to_vec, anchor=west] (STR_TO_VEC_\thecnt) {stream to vector};
\draw[->]
(STR_TO_VEC_\thecnt.east)
to
++(1.5, 0)
node[modulus2, anchor=west] (MODULUS2_\thecnt) {$\norm{\cdot}^2$};
\draw[->]
(MODULUS2_\thecnt.east)
to
++(1.5, 0)
node[thresh, anchor=west] (THRESHOLD_\thecnt) {threshold};
\stepcounter{cnt}
}
\draw[->]
(
$(PFB_CHANNELIZER.north east)
!0.85!
(PFB_CHANNELIZER.south east)$
)
coordinate (PFB_3)
to
++(1.5, 0)
node[str_to_vec, anchor=west] (STR_TO_VEC_3) {stream to vector};
\draw[->]
(STR_TO_VEC_3.east)
to
++(1.5, 0)
node[modulus2, anchor=west] (MODULUS2_3) {$\norm{\cdot}^2$};
\draw[->]
(MODULUS2_3.east)
to
++(1.5, 0)
node[thresh, anchor=west] (THRESHOLD_3) {threshold};
\draw[dottedline]
(STR_TO_VEC_1.south)
--
(STR_TO_VEC_3.north);
\draw[dottedline]
(MODULUS2_1.south)
--
(MODULUS2_3.north);
\draw[dottedline]
(THRESHOLD_1.south)
--
(THRESHOLD_3.north);
\end{tikzpicture}
\end{document}
Upvotes: 1
Reputation: 38748
The problem is that you are drawing your arrows from the previous arrow and not from the previous node. If you add a name to your nodes instead (foo
in the example below), the new arrow won't be drawn over the old node:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage{amsmath, amssymb, mathtools}
\usepackage{physics}
\newcounter{cnt}\setcounter{cnt}{0}
\begin{document}
\tikzset{str_to_vec/.style = {rectangle, draw, minimum width=3cm, text centered}}
\tikzset{modulus2/.style = {rectangle, draw, text centered}}
\tikzset{thresh/.style = {rectangle, draw, text centered}}
\tikzset{dottedline/.style = {ultra thick, loosely dotted,shorten >=1mm, shorten <=1mm}}
\begin{tikzpicture}[>=latex]
\draw[->]
(0,0)
to
++(5, 0)
coordinate (MODULUS2_3)
node[modulus2, anchor=west] (foo) {$\norm{\cdot}^2$};
\draw[->]
(foo)
to
++(5, 0)
coordinate (THRESHOLD_3)
node[thresh, anchor=west] {threshold};
\end{tikzpicture}
\end{document}
Upvotes: 1