# define domain relative to a node in tikz

I need to place sine waveform relative to the left and right of MOS transistor gate terminals using

\draw [domain=-4:-5, smooth] plot (\x, {3.5+0.6*sin(pi*2*\x r)});


But each time I need to define the domain relative to my gate terminals to place those waves. I tried to extract the x-coordinate using \pfgextractx and later \pgfgetlastxy, but didn't work. Probably I didn't code properly I guess. Is there is any way I can extract the x-coordinate of node (M1.G) and use it to define the domain.

\documentclass{article}
\usepackage[a4paper, margin=1.2in]{geometry}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\ctikzset{tripoles/mos style/arrows}
\usepackage{float}

%%My macros
\newcommand\Rlblmos[1]{($(M#1.G)+(1.3,-0.2)$) node [below] {$M_{#1}$}}
\newcommand\Llblmos[1]{($(M#1.G)+(-1.3,-0.2)$) node [below] {$M_{#1}$}}
\newcommand\lblvdd[2]{(M#1.#2)node [rground,yscale=-1] (vdd){}  ($(M#1.#2)+(0,0.75)$) node[right]{$V_{DD}$}}

\begin{document}

\begin{figure}[H]
\centering
\begin{circuitikz}

\def\Ba{0,.5} % This also works

\draw
(\Ba)node[ground]{}

($(\Ba)+(0,2)$) node[](vp){} to [I, l=$I_{SS}$] (\Ba){}
%define locations of MOS
($(vp)+(-2,1)$) node[nmos](M1){}\Rlblmos{1}
($(vp)+(2,1)$) node[nmos,xscale=-1](M2){}\Llblmos{2}
($(vp)+(-2,4)$) node[pmos,emptycircle,xscale=-1](M3){}\Llblmos{3}
($(vp)+(2,4)$) node[pmos,emptycircle](M4){}\Rlblmos{4}

(M4.S)node[circ](vdd2){}
(M3.S)node[circ](vdd1){}
(M1.S)|-(vp)node [circ] {}
(M2.S)|-(vp)
(M3.D)--($(M3.D)+(0,-.5)$)node[circ]{}-|($(M3.G)!0.5!(M4.G)$)node[circ]{}
(M3.G)--(M4.G)
(M4.D)--(M2.D) ($(M4.D)!0.5!(M2.D)$)node[circ](vout){}--($(vout)+(0.5,0)$)node[circ]{}node[right]{$v_{out}$}
($(M3.D)+(0,-0.5)$)--(M1.D)
(M1.G)node[circ]{}node[left]{$V_{in1}$}
(M2.G)node[circ]{}node[right]{$V_{in2}$}
;
\draw[line width=0.5mm]($(vdd1)+(-0.5,0)$)--($(vdd2)+(0.5,0)$);

\draw [domain=-4:-5, smooth] plot (\x, {3.5+0.6*sin(pi*2*\x r)});
\end{circuitikz}
\label{DiffAmp2.1}
\end{figure}

\end{document}


If you first give the V_{in1} node a name, e.g. node[left] (x) {$V_{in1}$}, then you can use shift=(x.west) to move the origin of a path to the west anchor of x. To draw one cycle to the left of that node, simply set the domain to be from -1 to 0, i.e.

 \draw [domain=-1:0, smooth,shift=(x.west)] plot (\x, {0.6*sin(pi*2*\x r)});


For a wave on the right, use the east anchor, and set the domain from 0 to 1.

\documentclass{article}
\usepackage[a4paper, margin=1.2in]{geometry}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\ctikzset{tripoles/mos style/arrows}
\usepackage{float}

%%My macros
\newcommand\Rlblmos[1]{($(M#1.G)+(1.3,-0.2)$) node [below] {$M_{#1}$}}
\newcommand\Llblmos[1]{($(M#1.G)+(-1.3,-0.2)$) node [below] {$M_{#1}$}}
\newcommand\lblvdd[2]{(M#1.#2)node [rground,yscale=-1] (vdd){}  ($(M#1.#2)+(0,0.75)$) node[right]{$V_{DD}$}}

\begin{document}

\begin{figure}[H]
\centering
\begin{circuitikz}

\def\Ba{0,.5} % This also works

\draw
(\Ba)node[ground]{}

($(\Ba)+(0,2)$) node[](vp){} to [I, l=$I_{SS}$] (\Ba){}
%define locations of MOS
($(vp)+(-2,1)$) node[nmos](M1){}\Rlblmos{1}
($(vp)+(2,1)$) node[nmos,xscale=-1](M2){}\Llblmos{2}
($(vp)+(-2,4)$) node[pmos,emptycircle,xscale=-1](M3){}\Llblmos{3}
($(vp)+(2,4)$) node[pmos,emptycircle](M4){}\Rlblmos{4}

(M4.S)node[circ](vdd2){}
(M3.S)node[circ](vdd1){}
(M1.S)|-(vp)node [circ] {}
(M2.S)|-(vp)
(M3.D)--($(M3.D)+(0,-.5)$)node[circ]{}-|($(M3.G)!0.5!(M4.G)$)node[circ]{}
(M3.G)--(M4.G)
(M4.D)--(M2.D) ($(M4.D)!0.5!(M2.D)$)node[circ](vout){}--($(vout)+(0.5,0)$)node[circ]{}node[right]{$v_{out}$}
($(M3.D)+(0,-0.5)$)--(M1.D)
(M1.G)node[circ]{}node[left] (x) {$V_{in1}$}
(M2.G)node[circ]{}node[right] (x2) {$V_{in2}$}
;
\draw[line width=0.5mm]($(vdd1)+(-0.5,0)$)--($(vdd2)+(0.5,0)$);

\draw [domain=-1:0, smooth,shift=(x.west)] plot (\x, {0.6*sin(pi*2*\x r)});
\draw [domain=0:1, smooth,shift=(x2.east)] plot (\x, {0.6*sin(pi*2*\x r)});
\end{circuitikz}

• ,@TorbjørnT. -- (+1) Missing (x2) in line 40, though. It should read (M2.G)node[circ]{}node[right](x2){$V_{in2}$}. – AboAmmar Feb 6 '17 at 12:51