我有下图
如您所见,子标题(b)
未居中于相应的子图(如)(a)
。如果我增加该值,[.51\linewidth]
则会发生不必要的事情。我使用subcaption
带有的包,memoir
因为 s 的本机回忆录工具subfigure
显示右对齐问题。上图的代码是:
\documentclass[11pt]{memoir}
\setstocksize{23cm}{15.9cm}
\settrimmedsize{23cm}{15.9cm}{*}
\settrims{0pt}{0pt}
\settypeblocksize{17.8cm}{11.3cm}{*}
\setlrmargins{2.3cm}{*}{*}
\setulmargins{6.4\onelineskip}{*}{*}
\setheadfoot{1.18\onelineskip}{\onelineskip}
\setheaderspaces{4.1\onelineskip}{*}{*}
\checkandfixthelayout[lines]
\usepackage{amsmath,amssymb,amsthm}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{subcaption}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows}
\pgfplotsset{
/pgfplots/area style/.style={%
area cycle list,
area legend,
axis on top,
}}
\begin{document}
\blindtext\blindtext
\begin{figure}[b]
%\centering
\subcaptionbox{A cat\label{cat}}{\begin{tikzpicture}[scale=0.71]
\begin{axis}[axis equal,axis on top,axis lines=center,enlargelimits=false,xlabel=$x(t)$,ylabel=$y(t)$,xmax=2.5,xmin=-2.2,ymax=2.5,ymin=-2.2,area legend,xtick=\empty,ytick= \empty %,legend entries={$\Ran f$}]
\addplot[draw=blue!30!white,fill=blue!30!white,
domain=-2:2,samples=120] {sqrt(4-x^2)};
%\addlegendimage{fill=blue!30!white,area legend}
%\addlegendentry{$\Ran f$}
\addplot[draw=blue!30!white,fill=blue!30!white,
domain=-2:2,samples=120] {-sqrt(4-x^2)};
\addplot[white,fill,
domain=-1:1,samples=120] {sqrt(1-x^2)};
\addplot[white,fill,
domain=-1:1,samples=120] {-sqrt(1-x^2)};
%\node at (380,170) {$x'(t)$};
%\node at (20,170) {$y'(t)$};
\end{axis}
\end{tikzpicture}}
\subcaptionbox{An elephant\label{elephant}}[.51\linewidth]
{\begin{tikzpicture}[scale=0.71,/pgf/declare function={f=1/x;}]
\begin{axis}[axis x line=center,axis y line=center,xtick=\empty,ytick= \empty,xlabel=$x(t)$,
ylabel=$y(t)$,]
\addplot [red!30!white,name path=f,domain=-3:3, samples=60] {f};
\path[name path=axis] (axis cs:\pgfkeysvalueof{/pgfplots/xmin},0) -- (axis cs:\pgfkeysvalueof{/pgfplots/xmax},0);
\addplot[red!30!white] fill between[of=f and axis];
\end{axis}
\end{tikzpicture}}
\caption{Two animals}\label{animals}
\end{figure}
\end{document}
我该如何控制它?
答案1
而不是将其scale=0.71
传递tikzpicture
给axis
选项。我还添加了ylabel style={anchor=west}
将 y 标签放上去。
\documentclass[11pt]{memoir}
\setstocksize{23cm}{15.9cm}
\settrimmedsize{23cm}{15.9cm}{*}
\settrims{0pt}{0pt}
\settypeblocksize{17.8cm}{11.3cm}{*}
\setlrmargins{2.3cm}{*}{*}
\setulmargins{6.4\onelineskip}{*}{*}
\setheadfoot{1.18\onelineskip}{\onelineskip}
\setheaderspaces{4.1\onelineskip}{*}{*}
\checkandfixthelayout[lines]
\usepackage{amsmath,amssymb,amsthm}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{subcaption}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows}
\pgfplotsset{
/pgfplots/area style/.style={%
area cycle list,
area legend,
axis on top,
}}
\begin{document}
\blindtext\blindtext
\begin{figure}[b]
%\centering
\subcaptionbox{A cat\label{cat}}{\begin{tikzpicture}
\begin{axis}[scale=0.71,axis equal,axis on top,axis lines=center,enlargelimits=false,xlabel=$x(t)$,ylabel=$y(t)$,xmax=2.5,xmin=-2.2,ymax=2.5,ymin=-2.2,area legend,xtick=\empty,ytick= \empty,
ylabel style={anchor=west} %,legend entries={$\Ran f$}
]
\addplot[draw=blue!30!white,fill=blue!30!white,
domain=-2:2,samples=120] {sqrt(4-x^2)};
%\addlegendimage{fill=blue!30!white,area legend}
%\addlegendentry{$\Ran f$}
\addplot[draw=blue!30!white,fill=blue!30!white,
domain=-2:2,samples=120] {-sqrt(4-x^2)};
\addplot[white,fill,
domain=-1:1,samples=120] {sqrt(1-x^2)};
\addplot[white,fill,
domain=-1:1,samples=120] {-sqrt(1-x^2)};
%\node at (380,170) {$x'(t)$};
%\node at (20,170) {$y'(t)$};
\end{axis}
\end{tikzpicture}}
\subcaptionbox{An elephant\label{elephant}}[.51\linewidth]
{\begin{tikzpicture}[/pgf/declare function={f=1/x;}]
\begin{axis}[scale=0.71,axis x line=center,axis y line=center,xtick=\empty,ytick= \empty,xlabel=$x(t)$,
ylabel=$y(t)$,,
ylabel style={anchor=west}]
\addplot [red!30!white,name path=f,domain=-3:3, samples=60] {f};
\path[name path=axis] (axis cs:\pgfkeysvalueof{/pgfplots/xmin},0) -- (axis cs:\pgfkeysvalueof{/pgfplots/xmax},0);
\addplot[red!30!white] fill between[of=f and axis];
\end{axis}
\end{tikzpicture}}
\caption{Two animals}\label{animals}
\end{figure}
\end{document}