3

I need to place both of these funcionts in 1 line, side by side with caption beneith, I tried all options, and to combine them, nothing worked. When I try to use minipage to divide 1 line to two parts, it says like it can't pair up with figure and tikz bellow, or something like that, can't make them in 1 line.. Any thoughs? Tnx for help.

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,arrows,shapes,automata,background,petri,patterns,shadows,fadings,decorations,decorations.text,circuits.logic.US}
\usepackage{circuitikz}
\usepackage{ifthen}
\begin{document} 
\begin{figure}[h]
\begin{tikzpicture}[scale=0.75]
     \begin{axis}
    [grid=major,xmin=-5,xmax=5,ymin=-20,ymax=20 ,xlabel=$x$,ylabel=$y$]
        \foreach \a [count=\xi] in {-2.4,-2.1,...,2.4}
        { 
        \ifodd\xi           
            \addplot[blue!100,line width=1pt]  plot expression{\a*(\x^2)-3*\x+cos(90*\x)};
        \else
            \addplot[orange!100, dashed, line width=1pt] plot expression    {\a*(\x^2)-3*\x+cos(90*\x)};        
        \fi }                   
    \end{axis}
\end{tikzpicture}
\caption{Serija složenih funkcija}
\begin{tikzpicture}[scale=0.75]
\begin{axis}
[grid=major,xmin=0,xmax=3,xlabel=$t$,ylabel={$x(t),y(t)$},variable=\t]  
\addplot [blue,line width=1pt,smooth] plot [domain=0:3.5,samples=350]expression{(1+2*t)*exp(-2*t)*sin(280*t*3.14)}; 
\addplot [red, line width=1pt,smooth,style=dashed] plot [domain=0:3.5,samples=150] expression{(1+2*t)*exp(-2*t)};
\addplot [red, line width=1pt,smooth,style=dashed] plot [domain=0:3.5,samples=150] expression{-(1+2*t)*exp(-2*t)};   
\end{axis}
\end{tikzpicture}
\caption{Damping sinusne funkcije}
\label{damping}
\end{figure}
\end{document}

this is how my document looks like and the picture bellow is what it need to be like, don't know how to align them. enter image description here

enter image description here

1 Answers1

2

The minipages are needed to center the captions. I also had to reduce the scale slightly to get the tikzpictures to fit.

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,arrows,shapes,automata,petri,patterns,shadows,fadings,decorations.text,circuits.logic.US}
\usepackage{circuitikz}
\usepackage{ifthen}
\usepackage{showframe}% debugging tool

\begin{document} 
\begin{figure}[h]
\hfil\begin{minipage}[t]{0.45\textwidth}
\centering\begin{tikzpicture}[scale=0.6]
     \begin{axis}
    [grid=major,xmin=-5,xmax=5,ymin=-20,ymax=20 ,xlabel=$x$,ylabel=$y$]
        \foreach \a [count=\xi] in {-2.4,-2.1,...,2.4}
        { 
        \ifodd\xi           
            \addplot[blue!100,line width=1pt]  plot expression{\a*(\x^2)-3*\x+cos(90*\x)};
        \else
            \addplot[orange!100, dashed, line width=1pt] plot expression    {\a*(\x^2)-3*\x+cos(90*\x)};        
        \fi }                   
    \end{axis}
\end{tikzpicture}
\caption{Serija složenih funkcija}
\end{minipage}\hfil
\begin{minipage}[t]{0.45\textwidth}
\centering\begin{tikzpicture}[scale=0.6]
\begin{axis}
[grid=major,xmin=0,xmax=3,xlabel=$t$,ylabel={$x(t),y(t)$},variable=\t]  
\addplot [blue,line width=1pt,smooth] plot [domain=0:3.5,samples=350]expression{(1+2*t)*exp(-2*t)*sin(280*t*3.14)}; 
\addplot [red, line width=1pt,smooth,style=dashed] plot [domain=0:3.5,samples=150] expression{(1+2*t)*exp(-2*t)};
\addplot [red, line width=1pt,smooth,style=dashed] plot [domain=0:3.5,samples=150] expression{-(1+2*t)*exp(-2*t)};   
\end{axis}
\end{tikzpicture}
\caption{Damping sinusne funkcije}\label{damping}
\end{minipage}
\end{figure}
\end{document}

alaigned tikspictures

John Kormylo
  • 79,712
  • 3
  • 50
  • 120