我用 tikz 制作了所附图片。但我无法将三个图形放在图形的同一层。我希望块应该位于其他两个图形的零层。如果有人能帮忙,也附上了图形的代码。
\begin{figure}[H]
\centering
\pgfplotsset{every tick label/.append style={font=\huge}}
\begin{tikzpicture}[scale=0.5,transform shape]
\begin{axis}[
axis lines = middle,
xmin = 0,
xmax = 1.1,
ymin = -1.25,
ymax = 1.25,
xtick = {0,0.5,1},
ytick = {-1,0,1},
axis line style = thick,
xlabel style={right},
% xlabel style={at=(current axis.right of origin), anchor=west},
xlabel={\huge $t$},
ylabel style={above},
% ylabel style={at=(current axis.above origin), anchor=south},
ylabel={\huge $u(t)$},
extra y ticks = {0},
% extra x ticks = {0},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=4
},
x post scale=1.2,
y post scale=1.2,
clip=false
]
\addplot [
domain=0:1,
samples=300,
line width = 2pt, blue
] {sin(deg(2*pi*x))};
\addplot [
domain=0:1,
samples=300,
line width = 2pt, blue
] {sin(deg(2*pi*(x))))};
\end{axis}
\end{tikzpicture}
\tikzstyle{block} = [draw, fill=gray!30, rectangle,
minimum height=3em, minimum width=6em]
\begin{tikzpicture}
\node [block] (controller) {$LTI$};
\draw [-Latex] (controller) -- node [midway, above] {$y(t)$} (2,0);
\draw [-Latex] (-2,0) -- node [midway, above] {$u(t)$} (controller);
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5,transform shape]
\begin{axis}[
axis lines = middle,
xmin = 0,
xmax = 1.1,
ymin = -2,
ymax = 2,
xtick = {0,0.5,1},
ytick = {-1.5,0,1.5},
axis line style = thick,
xlabel style = {right},
% xlabel style={at=(current axis.right of origin), anchor=west},
xlabel={\huge $t$},
% ylabel style={at=(current axis.above origin), anchor=south},
ylabel style={above},
ylabel={\huge $y(t)$},
extra y ticks = {0},
% extra x ticks = {0},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=4
},
x post scale=1.2,
y post scale=1.2,
clip=false
]
\addplot [
domain=0:1,
samples=300,
line width = 2pt, blue
] {sin(deg(2*pi*x))};
\addplot [
domain=0:1,
samples=300,
line width = 2pt, red
] {1.5*sin(deg(2*pi*(x+(1/4))))};
\end{axis}
\end{tikzpicture}
\end{figure}
答案1
您需要按如下方式添加baseline=...
每个tikzpicture
内容:
\documentclass{article}
\usepackage{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{figure}[ht]
\centering
\pgfplotsset{every tick label/.append style={font=\huge}}
\begin{tikzpicture}[baseline=(current bounding box.center), % <----
scale=0.5,transform shape]
\begin{axis}[
axis lines = middle,
xmin = 0,
xmax = 1.1,
ymin = -1.25,
ymax = 1.25,
xtick = {0,0.5,1},
ytick = {-1,0,1},
axis line style = thick,
xlabel style={right},
% xlabel style={at=(current axis.right of origin), anchor=west},
xlabel={\huge $t$},
ylabel style={above},
% ylabel style={at=(current axis.above origin), anchor=south},
ylabel={\huge $u(t)$},
extra y ticks = {0},
% extra x ticks = {0},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=4
},
x post scale=1.2,
y post scale=1.2,
clip=false
]
\addplot [
domain=0:1,
samples=300,
line width = 2pt, blue
] {sin(deg(2*pi*x))};
\addplot [
domain=0:1,
samples=300,
line width = 2pt, blue
] {sin(deg(2*pi*(x))))};
\end{axis}
\end{tikzpicture}
\tikzstyle{block} = [draw, fill=gray!30, rectangle,
minimum height=3em, minimum width=6em]
\begin{tikzpicture}[baseline={([yshift=1.4ex] current bounding box.center)}] % <----
\node [block] (controller) {$LTI$};
\draw [-Latex] (controller) -- node [midway, above] {$y(t)$} (2,0);
\draw [-Latex] (-2,0) -- node [midway, above] {$u(t)$} (controller);
\end{tikzpicture}
\begin{tikzpicture}[baseline=(current bounding box.center), % <----
scale=0.5,transform shape]
\begin{axis}[
axis lines = middle,
xmin = 0,
xmax = 1.1,
ymin = -2,
ymax = 2,
xtick = {0,0.5,1},
ytick = {-1.5,0,1.5},
axis line style = thick,
xlabel style = {right},
% xlabel style={at=(current axis.right of origin), anchor=west},
xlabel={\huge $t$},
% ylabel style={at=(current axis.above origin), anchor=south},
ylabel style={above},
ylabel={\huge $y(t)$},
extra y ticks = {0},
% extra x ticks = {0},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=4
},
x post scale=1.2,
y post scale=1.2,
clip=false
]
\addplot [
domain=0:1,
samples=300,
line width = 2pt, blue
] {sin(deg(2*pi*x))};
\addplot [
domain=0:1,
samples=300,
line width = 2pt, red
] {1.5*sin(deg(2*pi*(x+(1/4))))};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}