我對 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{軸}[ width=2in, ymin=0, xmin=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]
...