3

I am trying to draw some boxes on a row, each one positioned relative to the previous one. With very little luck. What am I doing wrong here ?

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{pgfplots}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\pgfplotsset{ticks=none}
\pgfplotsset{compat=1.13} 
\begin{document}

\begin{tikzpicture}

\node[draw, rectangle, pos=.5, align=center] (ClarkeBox)  { \tiny Clarke \\ \tiny transform};
\node[draw, rectangle, right=of ClarkeBox, pos=.5, align=center] (ParkBox)  { \tiny Park \\ \tiny transform};
\node[draw, rectangle, right=of ParkBox, fill=gray!25, pos=.5, align=center] (CtrlBox)  { \tiny Control \\ \tiny process};
\node[draw, rectangle, right=of CtrlBox, pos=.5, align=center] (InvParkBox)  { \tiny Inverse \\ \tiny Park \\ \tiny transform};
\node[draw, rectangle, right=of InvParkBox, pos=.5, align=center] (InvClarkeBox)  { \tiny Inverse \\ \tiny Clarke \\ \tiny transform};
\node[draw, rectangle, below=of CtrlBox, pos=.5, align=center] (RefBox)  { \tiny reference};
\node[draw, rectangle, right=of InvClarkeBox, pos=.5, align=center] (ModulationBox)  { \tiny Output \\ \tiny Voltage \\ \tiny Modulation};
\end{tikzpicture}
\end{document} 

enter image description here

  • 1
    pos key works for putting nodes on paths. You are placing directly. – percusse Dec 29 '16 at 12:49
  • Not sure if I understand. The "pos=.5" is used to place the text inside the node in this example. – fluxmodel Dec 29 '16 at 12:51
  • 3
    Try to remove pos=.5... – Paul Gaborit Dec 29 '16 at 12:57
  • Aha. I stand duly corrected. Thanks both of you. – fluxmodel Dec 29 '16 at 12:58
4

Answering my own question here. Thanks to the comments above (from percusse and Paul Gaborit), and despite my misconception about the key pos, the whole think worked when I removed all of the pos=.5. I though that key was needed to properly place the text inside the node.

anyway, full code below:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{pgfplots}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows}
\pgfplotsset{ticks=none}
\pgfplotsset{compat=1.13} 
\begin{document}

\begin{tikzpicture}

\node[draw, rectangle, align=center] (ClarkeBox)  {  Clarke \\  transform};
\node[draw, rectangle, right=of ClarkeBox,  align=center] (ParkBox)  {  Park \\  transform};
\node[draw, rectangle, right=of ParkBox, fill=gray!25, align=center] (CtrlBox)  {  Control \\  process};
\node[draw, rectangle, right=of CtrlBox, align=center] (InvParkBox)  {  Inverse \\  Park \\  transform};
\node[draw, rectangle, right=of InvParkBox, align=center] (InvClarkeBox)  {  Inverse \\  Clarke \\  transform};
\node[draw, rectangle, below=of CtrlBox, align=center] (RefBox)  {  reference};
\node[draw, rectangle, right=of InvClarkeBox,  align=center] (ModulationBox)  {  Output \\  Voltage \\  Modulation};


\draw[red] ([shift={(0,0.25)}]ClarkeBox.west) --++ (-1,0)       node[left]{{\scriptsize  $i_U$}};
\draw[blue]  (ClarkeBox.west)--++ (-1,0)                        node[left]{{\scriptsize  $i_U$}};
\draw[green] ([shift={(0,-0.25)}]ClarkeBox.west) --++ (-1,0)    node[left]{{\scriptsize  $i_U$}};

\draw[violet] ([shift={(0,0.15)}]ClarkeBox.east) -- ([shift={(0,0.15)}]ParkBox.west) node[midway, above] (alpha1) {\scriptsize  $i_{\alpha}$};
\draw[orange] ([shift={(0,-0.15)}]ClarkeBox.east) -- ([shift={(0,-0.15)}]ParkBox.west) node[midway, below] (beta1) {\scriptsize $i_{\beta}$};

\draw[violet] ([shift={(0,0.15)}]ParkBox.east) -- ([shift={(0,0.15)}]CtrlBox.west) node[midway, above] {\scriptsize  $i_q$};
\draw[orange] ([shift={(0,-0.15)}]ParkBox.east) -- ([shift={(0,-0.15)}]CtrlBox.west) node[midway, below] {\scriptsize  $i_d$};

\draw[violet] ([shift={(0,0.15)}]CtrlBox.east) -- ([shift={(0,0.15)}]InvParkBox.west) node[midway, above] {\scriptsize  $i_q$};
\draw[orange] ([shift={(0,-0.15)}]CtrlBox.east) -- ([shift={(0,-0.15)}]InvParkBox.west) node[midway, below] {\scriptsize  $i_d$};

\draw[violet] ([shift={(0,0.15)}]InvParkBox.east) -- ([shift={(0,0.15)}]InvClarkeBox.west) node[midway, above] {\scriptsize  $i_{\alpha}$};
\draw[orange] ([shift={(0,-0.15)}]InvParkBox.east) -- ([shift={(0,-0.15)}]InvClarkeBox.west) node[midway, below] {\scriptsize  $i_{\beta}$};

\draw[red] ([shift={(0,0.25)}]InvClarkeBox.east) -- ([shift={(0,0.25)}]ModulationBox.west);%  node[right] {\scriptsize $U$} ;
\draw[blue] ([shift={(0,0.0)}]InvClarkeBox.east)    -- ([shift={(0,0.0)}]ModulationBox.west);% node[right] {\scriptsize  $V$};
\draw[green] ([shift={(0,-0.25)}]InvClarkeBox.east)  -- ([shift={(0,-0.25)}]ModulationBox.west);% node[right] {\scriptsize  $W$};

\draw[-o,red] ([shift={(0,0.25)}]ModulationBox.east) --++ (1,0) node[right] {\scriptsize $v_U$} ;
\draw[-o,blue] ([shift={(0,0.0)}]ModulationBox.east)    --++ (1,0) node[right] {\scriptsize  $v_V$};
\draw[-o,green] ([shift={(0,-0.25)}]ModulationBox.east)  --++ (1,0) node[right] {\scriptsize  $v_W$};



\draw[dashed, gray] (ClarkeBox.north) --++ (0,1.5);
\draw[dashed, gray] (ParkBox.north) --++ (0,1.5);
\draw[dashed, gray] (CtrlBox.north) --++ (0,1.5);
\draw[dashed, gray] (InvClarkeBox.north) --++ (0,1.5);
\draw[dashed, gray] (InvParkBox.north) --++ (0,1.5);

\draw[violet, <-] ([shift={(-0.15,0)}]CtrlBox.south) --++ (0,-1) node[midway, left]{\scriptsize $ i_q^* $};
\draw[orange, <-] ([shift={(0.15,0)}]CtrlBox.south) --++ (0,-1) node[midway, right]{\scriptsize $ i_d^* $};



\begin{axis}[at={($(ClarkeBox.north west)+(-1cm,0.5cm)$)},trig format plots=rad,axis lines = middle,clip=false,xmax = 2.75*pi,ymax = 1.5,ymin = -0.5,y=0.4cm,x=0.12 cm]
    \addplot[color=red, domain=0:2.25*pi,samples=200] {sin(x)};% node [above right, font=\scriptsize] {$i_U$}; 
    \addplot[color=blue, domain=0:2.25*pi,samples=200] {sin(x+(2/3 * pi))};%  node [below right, font=\scriptsize] {$i_V$};
    \addplot[color=green, domain=0:2.25*pi,samples=200] {sin(x-(2/3* pi))};% node [ right, font=\scriptsize] {$i_W$};
\end{axis}

\begin{axis}[at={($(ClarkeBox.north east)+(0cm,0.5cm)$)},trig format plots=rad,axis lines = middle,clip=false,xmax = 2.75*pi,ymax = 1.5,ymin = -0.5,y=0.4cm,x=0.12 cm]
    \addplot[color=violet, domain=0:2.4*pi,samples=200] {0.8*sin(x)};% node [above   right, font=\scriptsize] {$i_{\alpha}$};
    \addplot[color=orange, domain=0:2.4*pi,samples=200] {0.6*sin(x+(1/2 * pi))};% node [below right, font=\scriptsize] {$i_{\beta}$};
\end{axis}

\begin{axis}[at={($(ParkBox.north east)+(0cm,0.5cm)$)},trig format plots=rad,axis lines = middle,clip=false,xmax = 34,ymax = 1.5,ymin = -0.5,y=0.4cm,x=0.1 cm]
    \addplot[color=violet, domain=0:17,samples=2] {0.8};% node [above    right, font=\scriptsize] {$i_q$};
    \addplot[color=violet, domain=17:34,samples=2] {1.1};% node [above   right, font=\scriptsize] {$i_q$};
    \draw[color=violet] (axis cs:17,0.8) -- (axis cs:17,1.1);
    \addplot[color=orange, domain=0:17,samples=2] {0.5};% node [below right, font=\scriptsize] {$i_d$};
    \addplot[color=orange, domain=17:34,samples=2] {0.7};% node [below right, font=\scriptsize] {$i_d$};
    \draw[color=orange] (axis cs:17,0.5) -- (axis cs:17,0.7);
\end{axis}

\begin{axis}[at={($(InvParkBox.north east)+(0cm,0.5cm)$)},trig format plots=rad,axis lines = middle,clip=false,xmax = 2.75*pi,ymax = 1.5,ymin = -0.5,y=0.4cm,x=0.12 cm]
    \addplot[color=violet, domain=0:2.4*pi,samples=200] {1.1*sin(x)};% node [above   right, font=\scriptsize] {$i_{\alpha}$};
    \addplot[color=orange, domain=0:2.4*pi,samples=200] {0.7*sin(x+(1/2 * pi))};% node [below right, font=\scriptsize] {$i_{\beta}$};
\end{axis}

\begin{axis}[at={($(InvClarkeBox.north east)+(0cm,0.5cm)$)},trig format plots=rad,axis lines = middle,clip=false,xmax = 2.75*pi,ymax = 1.5,ymin = -0.5,y=0.4cm,x=0.12 cm]
\addplot[color=red, domain=0:2.25*pi,samples=200] {sin(x)};% node [above right, font=\scriptsize] {$i_U$}; 
\addplot[color=blue, domain=0:2.25*pi,samples=200] {sin(x+(2/3 * pi))};%  node [below right, font=\scriptsize] {$i_V$};
\addplot[color=green, domain=0:2.25*pi,samples=200] {sin(x-(2/3* pi))};% node [ right, font=\scriptsize] {$i_W$};
\end{axis}

\begin{axis}[at={($(ModulationBox.north east)+(0cm,0.5cm)$)},trig format plots=rad,axis lines = middle,clip=false,xmax = 2.75*pi,ymax = 1.5,ymin = -0.5,y=0.4cm,x=0.12 cm]
    \addplot[->,color=red, domain=0:2.25*pi,samples=200] {sin(x) + (1/5)*sin(3*x)};% node [above right, font=\scriptsize] {$u_U$}; 
    \addplot[->,color=blue, domain=0:2.25*pi,samples=200] {sin(x+(2/3 * pi)) + (1/5)*sin(3*x)};%  node [below right, font=\scriptsize] {$u_V$};
    \addplot[->,color=green, domain=0:2.25*pi,samples=200] {sin(x-(2/3* pi)) + (1/5)*sin(3*x)};% node [ right, font=\scriptsize] {$u_W$};
\end{axis}


\end{tikzpicture}


\end{document} 

enter image description here

  • 1
    Many compliments. – Sebastiano Dec 29 '16 at 13:27
  • 1
    You may have looked at the manual already, but when you do something like \draw (a) -- (b) node[pos=x]{...};, the pos key determines where along the path from a to b the node is placed. With pos=0 it is placed at a, with pos=1 it is placed at b, and 0.5 is halfway between them. – Torbjørn T. Dec 29 '16 at 13:30
  • I understand. First, i used \draw[] (0.0) rectangle++ (2,2) node[pos=0.5] {Text} to get the text centered inside the rectangle, but when I changed to \node[rectangle] it seems as if that part was no longer needed. – fluxmodel Dec 29 '16 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.