我正在尝试将两个 tikz 轴并排放置。我目前将每个轴封装在一个子图中,但似乎 tikz 图形周围有太多空白,即使我将宽度设置为,我也几乎看不到图片0.5\tetxwidth
。我有以下代码,如能帮助我将不胜感激!
\begin{figure*}
\begin{center}
\begin{subfigure}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
width=0.5\textwidth,
axis lines=middle,xmin=-1.2,xmax=1.2,ymin=-1.2,ymax=1.2,
xlabel=$\scriptstyle x$,ylabel=$\scriptstyle y$,
yticklabels=\empty,
xticklabels=\empty,
axis equal]
\begin{scope}
\clip (0, 0) rectangle (1, 1);
\clip (0, 0)--(0.33, 1)--(0, 1)--cycle;
\fill[yellow, opacity=0.6] (0, 0) circle (1);
\end{scope}
\addplot+[name path = gaussian, no marks,
domain=-1.5:1.5,samples=15] {3*x};
\draw[name path = line] (axis cs:0,0) circle [blue, radius=1];
\end{axis}
\end{tikzpicture}
\end{subfigure}\hfill
\begin{subfigure}[t]{.5\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
width=0.5\textwidth,
axis lines=middle,xmin=-1.2,xmax=1.2,ymin=-1.2,ymax=1.2,
xlabel=$\scriptstyle x$,ylabel=$\scriptstyle y$,
yticklabels=\empty,
xticklabels=\empty,
axis equal
]
\begin{scope}
\clip (0, 0) rectangle (1, 1);
\clip (0, 0)--(0.33, 1)--(0, 1)--cycle;
\fill[yellow, opacity=0.6] (0, 0) circle (1);
\end{scope}
\addplot+[name path = gaussian, no marks,
domain=-1.5:1.5,samples=15] {3*x};
\draw[name path = line] (axis cs:0,0) circle [blue, radius=1];
\end{axis}
\end{tikzpicture}
\end{subfigure}
\end{center}
\end{figure*}
答案1
省略width=0.5\textwidth
。
请在您的序言中发布一个最小示例,因为它是我发明的,可能与您的实际文档不同。
\documentclass[margin=2in]{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure*}
\begin{center}
\begin{subfigure}[t]{0.4\linewidth}
\centering
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
% width=0.5\textwidth,
axis
lines=middle,xmin=-1.2,xmax=1.2,ymin=-1.2,ymax=1.2,
xlabel=$\scriptstyle x$,ylabel=$\scriptstyle y$,
yticklabels=\empty,
xticklabels=\empty,
axis equal]
\begin{scope}
\clip (0, 0) rectangle (1, 1);
\clip (0, 0)--(0.33, 1)--(0, 1)--cycle;
\fill[yellow, opacity=0.6] (0, 0) circle (1);
\end{scope}
\addplot+[name path = gaussian, no marks,
domain=-1.5:1.5,samples=15] {3*x};
\draw[name path = line] (axis cs:0,0) circle [blue, radius=1];
\end{axis}
\end{tikzpicture}
\end{subfigure}\hfill
\begin{subfigure}[t]{.4\linewidth}
\centering
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
% width=0.5\textwidth,
axis lines=middle,xmin=-1.2,xmax=1.2,ymin=-1.2,ymax=1.2,
xlabel=$\scriptstyle x$,ylabel=$\scriptstyle y$,
yticklabels=\empty,
xticklabels=\empty,
axis equal
]
\begin{scope}
\clip (0, 0) rectangle (1, 1);
\clip (0, 0)--(0.33, 1)--(0, 1)--cycle;
\fill[yellow, opacity=0.6] (0, 0) circle (1);
\end{scope}
\addplot+[name path = gaussian, no marks,
domain=-1.5:1.5,samples=15] {3*x};
\draw[name path = line] (axis cs:0,0) circle [blue, radius=1];
\end{axis}
\end{tikzpicture}
\end{subfigure}
\end{center}
\end{figure*}
\end{document}