我对 pgfplots 还很陌生。
我正在尝试绘制两个图形,并让它们并排绘制。但是,当我使用子图时,我的绘图(和轴标签)重叠了。我该如何解决这个问题?
\documentclass{amsart}
\usepackage{amsthm, amsfonts, amsmath, amssymb, mathrsfs, enumerate,graphicx}
\usepackage{pgfplots} %For creating plots inside LaTeX itself
\usepackage{subcaption} %To create subfigures
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.45\linewidth}\centering
\begin{tikzpicture}
\begin{axis}[
ymin=0, xmin=0,
%grid=major, % activate major grid lines
xlabel=$\text{radius, }r$,
ylabel=$\text{concentration, }c$,
title={Steady state concentration},
title style={yshift=1.5ex},
axis on top, % descriptions over filled area
legend pos=outer north east, % customize legend
]
\addplot[smooth,blue,domain=0.5:2]
{((1-0.00167)*ln(x)+0.00167*ln(0.5)-1*ln(2))/(ln(0.5)-ln(2))} ;
\end{axis}
\end{tikzpicture}
\caption{Steady state species concentration profile. }
\end{subfigure}
\begin{subfigure}{.45\linewidth}\centering
\begin{tikzpicture}
\begin{axis}[
ymin=0, xmin=0,
xlabel=$\text{radius, }r$,
ylabel=$\text{chemical potential, }\mu^{c^*}$,
title={Steady state chemical potential},
title style={yshift=1.5ex},
axis on top, % descriptions over filled area
legend pos=outer north east, % customize legend
]
\addplot[smooth,blue,domain=0.5:2]
{8.31*310*ln(((1-.00167)*ln(x)+.00167*ln(0.5)-1*ln(2))/(ln(0.5)-ln(2))/.00167)} ;
\end{axis}
\end{tikzpicture}
\caption{Steady state chemical potential profile}
\end{subfigure}
\caption{Illustration of analytical steady state solution.}
\end{figure}
\end{document}
答案1
的问题\begin{tikzpicture}[scale=0.65]
是字体也会缩放,使它们看起来更小。您可以使用width
提供的选项来调整图的宽度pgfplots
。您可以通过添加以下选项对所有图进行此操作:
\usepackage{pgfplots} %For creating plots inside LaTeX itself
\pgfplotsset{width=2in} %%<-------------------- this
或者只针对特定图,将其添加到“轴选项”中,例如
\begin{轴}[ 宽度=2 英寸, y 轴最小值=0, x 轴最小值=0, . .
现在字体保持相同的大小。此外,您可以scale only axis,
只缩放轴而不考虑刻度标签。最后,您可能希望添加
ylabel style={overlay, anchor=north,}, %%% <-- this added
使标签更靠近 y 轴。
\documentclass{amsart}
\usepackage{amsthm, amsfonts, amsmath, amssymb, mathrsfs, enumerate,graphicx}
\usepackage{pgfplots} %For creating plots inside LaTeX itself
\usepackage{subcaption} %To create subfigures
%\pgfplotsset{width=2in}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.45\linewidth}\centering
\begin{tikzpicture}
\begin{axis}[
width=\linewidth, %%<----- here
scale only axis, %%% <-- this added
ymin=0, xmin=0,
%grid=major, % activate major grid lines
xlabel=$\text{radius, }r$,
ylabel=$\text{concentration, }c$,
ylabel style={overlay, anchor=north,}, %%% <-- this added
title={Steady state concentration},
title style={yshift=1.5ex},
axis on top, % descriptions over filled area
legend pos=outer north east, % customize legend
]
\addplot[smooth,blue,domain=0.5:2]
{((1-0.00167)*ln(x)+0.00167*ln(0.5)-1*ln(2))/(ln(0.5)-ln(2))} ;
\end{axis}
\end{tikzpicture}
\caption{Steady state species concentration profile. }
\end{subfigure}%
\hfill
\begin{subfigure}{.45\linewidth}\centering
\begin{tikzpicture}
\begin{axis}[
width=\linewidth, %%<-------- here
scale only axis, %%% <-- this added
ymin=0, xmin=0,
xlabel=$\text{radius, }r$,
ylabel=$\text{chemical potential, }\mu^{c^*}$,
ylabel style={overlay, anchor=north,}, %%% <-- this added
title={Steady state chemical potential},
title style={yshift=1.5ex},
axis on top, % descriptions over filled area
legend pos=outer north east, % customize legend
]
\addplot[smooth,blue,domain=0.5:2]
{8.31*310*ln(((1-.00167)*ln(x)+.00167*ln(0.5)-1*ln(2))/(ln(0.5)-ln(2))/.00167)} ;
\end{axis}
\end{tikzpicture}
\caption{Steady state chemical potential profile}
\end{subfigure}
\caption{Illustration of analytical steady state solution.}
\end{figure}
\end{document}
答案2
两者皆用
\begin{tikzpicture}[scale=0.65]
...