![如何在乳胶主体中包含一个图形](https://linux22.com/image/462019/%E5%A6%82%E4%BD%95%E5%9C%A8%E4%B9%B3%E8%83%B6%E4%B8%BB%E4%BD%93%E4%B8%AD%E5%8C%85%E5%90%AB%E4%B8%80%E4%B8%AA%E5%9B%BE%E5%BD%A2.png)
我有一个这样的图,它有 2 个子图;如何将其包含在我的其他主文档中?我可以使用 \input{figure_name},该图会显示在我的父文档中。
\documentclass{article}
\usepackage{subcaption}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{adjustbox}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.4\textwidth}
\begin{tikzpicture}
\begin{axis}[
trig format=rad, % <---
domain=0:1, % <---
samples=501, % <---
no marks] % <---
\addplot {sin(10*x};
\legend{$\sin(10x)$}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.4\textwidth}
\begin{tikzpicture}
\begin{axis}[
trig format=rad, % <---
domain=0:1, % <---
samples=501, % <---
no marks] % <---
\addplot {sin(100*x};
\legend{$\sin(100x)$}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\caption{Increasing oscillatory function}
\end{figure}
\end{document}
答案1
像这样:
我假设两个图像具有相同的axis
设置,因此可以在本地写入\pgfplotsset
,从而使图形代码更短一些:
\documentclass{article}
\usepackage{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{figure}
\centering
\pgfplotsset{% common settings for both images
width=\linewidth,
scale only axis,
trig format=rad, % <---
domain=0:pi/2, % <---
samples=501, % <---
no marks, % <---
% added,˛
every axis plot post/.append style={semithick},
legend style={font=\footnotesize,
cells={anchor=west}}
}
\begin{subfigure}[b]{0.45\textwidth}
\begin{tikzpicture}
\begin{axis}
\addplot {sin(10*x};
\addplot {sin(25*x)};
\addplot {sin(50*x)};
\legend{$\sin(10x)$,$\sin(25x)$,$\sin(50x)$}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\hfil
\begin{subfigure}[b]{0.45\textwidth}
\begin{tikzpicture}
\begin{axis}
\addplot {sin(100*x)};
\addplot {sin(150*x))};
\addplot {sin(200*x))};
\legend{$\sin(100x)$,$\sin(150x)$,$\sin(200x)$}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\caption{Increasing oscillatory function}
\label{fig:??}
\end{figure}
\end{document}
如您所见,如果您有平行的图像,它们在给定的页面布局中会非常窄,因此不太清晰。要提高图表的可见性,您有几种选择:
- 更改页面布局并放大
\textwidth
- 将一张图片放在另一张图片之上
- 缩小第二幅图像的域
附录:
- 我想知道为什么你的子图没有标题
- 如果不需要,您可以考虑
groupplot
使用subfigures
- 在下面的 MWE 中,被视为:
- 第二幅图像的简化波域
\textwidth
通过使用geometry
包增加- 子图标题中的数量使用 ˙siunnitx` 包Č
\documentclass{article}
\usepackage{geometry} % for setting page layout
\usepackage{siunitx}
\usepackage[font=small]{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{figure}
\pgfplotsset{% common settings for both images
width=0.8\linewidth,
scale only axis,
enlargelimits = 0.05,
trig format=rad,
samples=801,
no marks,
% added, for better diagram formating
x tick label style={/pgf/number format/.cd, zerofill, fixed},
every axis plot post/.append style={semithick},
legend style={font=\footnotesize,
cells={anchor=west}}
}
\begin{subfigure}[b]{0.48\textwidth}
\begin{tikzpicture}
\begin{axis}[
domain=0:1, % <---
]
\addplot {sin(10*x};
\addplot {sin(25*x)};
\addplot {sin(50*x)};
\legend{$\sin(10x)$,$\sin(25x)$,$\sin(50x)$}
\end{axis}
\end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{1}{\radian}.}
\end{subfigure}
\hfil
\begin{subfigure}[b]{0.48\textwidth}
\begin{tikzpicture}
\begin{axis}[
domain=0:0.25, % <---
]
\addplot {sin(100*x)};
\addplot {sin(150*x)};
\addplot {sin(200*x)};
\legend{$\sin(100x)$,$\sin(150x)$,$\sin(200x)$}
\end{axis}
\end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{0.25}{\radian}.}
\end{subfigure}
\caption{Increasing oscillatory function}
\label{fig:??}
\end{figure}
\end{document}
\documentclass{article}
\usepackage{geometry} % for setting page layout
\usepackage{siunitx}
\usepackage[font=small]{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{figure}
\pgfplotsset{% common settings for both images
width=0.8\linewidth,
scale only axis,
enlargelimits = 0.05,
trig format=rad, % <---
samples=801, % <---
no marks, % <---
% added,
x tick label style={/pgf/number format/.cd, zerofill, fixed},
every axis plot post/.append style={semithick},
legend style={font=\footnotesize,
cells={anchor=west}}
}
\begin{subfigure}[b]{0.48\textwidth}
\begin{tikzpicture}
\begin{axis}[
domain=0:1, % <---
]
\addplot {sin(10*x};
\addplot {sin(25*x)};
\addplot {sin(50*x)};
\legend{$\sin(10x)$,$\sin(25x)$,$\sin(50x)$}
\end{axis}
\end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{1}{\radian}.}
\end{subfigure}
\hfil
\begin{subfigure}[b]{0.48\textwidth}
\begin{tikzpicture}
\begin{axis}[
domain=0:0.25, % <---
]
\addplot {sin(100*x)};
\addplot {sin(150*x)};
\addplot {sin(200*x)};
\legend{$\sin(100x)$,$\sin(150x)$,$\sin(200x)$}
\end{axis}
\end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{0.25}{\radian}.}
\end{subfigure}
\caption{Increasing oscillatory function}
\label{fig:??}
\end{figure}
\end{document}