我需要将这两个功能放在一行中,并排放置,标题放在下方,我尝试了所有选项,但都无法将它们组合在一起。当我尝试使用 minipage 将一行分成两部分时,它说它无法与下面的图形和 tikz 配对,或者类似的东西,无法将它们放在一行中。有什么想法吗?谢谢帮助。
\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}
答案1
需要minipage
用 s 来使标题居中。我还必须稍微缩小比例以使tikzpicture
s 适合。
\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}