3

Following the question here Draw a simple sine wave with help, I was able to draw the right-hand side picture. How to draw the left hand side and combine it?

Below is simple sine wave from the previous question.

enter image description here

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}

  \begin{tikzpicture}[font=\sffamily,
    declare function={f1(\x)=1.2*sin(2.5*deg(\x));
    f2(\x)=0.6*(1.2*sin(2*deg(\x))+1*sin(4*deg(\x))+1.2*sin(6*deg(\x)));
    }]
  \begin{scope}[yshift=-6cm,local bounding box=B]
   \draw[latex-latex](0,3)  node[above]{Amplitude} |- (10,0);
   \draw plot[domain=0:9,variable=\x,samples=101,smooth] ({\x},{f2(\x)});
  \end{scope}
 %
 \path foreach \X in {B} {(\X.south) node[below] {Time}}; 
\end{tikzpicture}


\end{document}
3
  • 1
    tex.stackexchange.com/a/422847/197451
    – js bibra
    Commented Dec 14, 2019 at 0:58
  • 2
    Is this really about 2 pictures in one row (from the title) or about how to draw the picture on the left (from the body)?
    – Teepeemm
    Commented Dec 14, 2019 at 4:33
  • @Teepeemm. I just want to draw a picture above.
    – aan
    Commented Dec 14, 2019 at 10:43

1 Answer 1

6

Please note that it might make a lot of sense to redo the left part with circutikz if you want to do more circuits, but you will be able to use it like in the example below. I just happen not to be very fluent in this, so I just use some basic and gates. The main question seems to be how one can arrange things horizontally. The answer is: just like in the answer you link to but use xshift instead of yshift.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{circuits,circuits.logic.US,matrix,positioning,shapes.geometric}
\begin{document}
\begin{tikzpicture}[font=\sffamily,circuit logic US,
    /pgf/logic gate input sep=2ex,
    declare function={f2(\x)=0.6*(1.2*sin(2*deg(\x))+1*sin(4*deg(\x))+1.2*sin(6*deg(\x)));
    }]
 \begin{scope}[local bounding box=L]
  \matrix[matrix of nodes,nodes={and gate},nodes in empty cells] (mat){
   \\[2em]
   \\[4em]
   \\
  };  
  \node[right=5em of mat,ellipse,draw,thick] (Sigma) {$\Sigma$}; 
  \foreach \X in {1,2,3}
  {\draw ([yshift=0.75ex]mat-\X-1.input 1) -- ++ (-2em,0) node[left]{$\ifnum\X=3
    \mathsf{Amp}_N(t)\else \mathsf{Amp}_\X(t)\fi$}; 
   \draw ([yshift=-0.75ex]mat-\X-1.input 2) -- ++ (-2em,0) node[left]{$\ifnum\X=3
    \mathsf{Freq}_N(t)\else \mathsf{Freq}_\X(t)\fi$};   
   \draw[thick,-latex] (mat-\X-1.output)  -- (Sigma);
  }% https://tex.stackexchange.com/a/52856/194703
  \draw[dash pattern=on .05mm off 4mm,line cap=round,line width = 2mm,
    shorten <=3mm]   (mat-2-1.south) -- (mat-3-1.north);
 \end{scope}
  %
 \begin{scope}[xshift=6cm,local bounding box=R]
   \draw[latex-latex](0,3)  node[above]{Amplitude} |- (10,0);
   \draw plot[domain=0:9,variable=\x,samples=101,smooth] ({\x},{f2(\x)});
 \end{scope}
 %
 \path (R.south) node[below] {Time};
 \draw[thick,-latex] (Sigma) -- (Sigma-|R.west);
\end{tikzpicture}
\end{document}

enter image description here

Please consult the link provided by js bibra for more options.

3
  • cat. Any idea how to reduce the diagram into smaller size? (because it was outside the page border). I tried to reduce those em from original into half of orginal em size for left-hand side diagram. But I could not find where to change the size of amplitude-time diagram.
    – aan
    Commented Dec 14, 2019 at 10:54
  • 1
    @aan Just replace \begin{scope}[xshift=6cm,local bounding box=R] by e.g. \begin{scope}[xshift=5cm,xscale=0.75,local bounding box=R]
    – user194703
    Commented Dec 14, 2019 at 11:04
  • Thanks a lot. Brillant!
    – aan
    Commented Dec 14, 2019 at 11:08

You must log in to answer this question.

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