定位 pgfplots 双列环境

定位 pgfplots 双列环境

我通常通过 来制作图表pgfplots。但是,我在环境中遇到了对齐问题twocolumn。事实上,如果我只生成一个图表,结果会与列正确对齐。当我在环境中执行此操作时,subfloat图表不会与单个图表对齐。我想知道是否有办法将 subfloat 环境中的图表与单个图表对齐。此外,有效图表的大小(不考虑标签)取决于标签本身(例如,当标签包含积分符号时)。有没有办法修复“有效”图表的大小?

下面举个例子来说明

在此处输入图片描述

\documentclass[twocolumn,10pt]{article}

\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{pgfplots}


\begin{document}

\begin{figure*}[!h]
\centering
\subfloat[graph A]
{
\begin{tikzpicture}
\begin{axis}[
    width=0.36\textwidth,
    height=0.27\textwidth,
]

\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]{x^2 - 2*x - 1};
\addlegendentry{\(x^2 - 2x - 1\)}


\end{axis}
\end{tikzpicture}}
%\hspace{3cm}
\subfloat[graph B]
{\label{fig:totalTemperatureAmp}
\begin{tikzpicture}
\begin{axis}[
    width=0.36\textwidth,
    height=0.27\textwidth,
]

\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]{x^2 - 2*x - 1};
\addlegendentry{\(x^2 - 2x - 1\)}


\end{axis}
\end{tikzpicture}}
\caption{graph in subfloat enviroment}
\label{fig:amplitudeBC}
\end{figure*}


\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.36\textwidth,
    height=0.27\textwidth,
]

\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]{x^2 - 2*x - 1};
\addlegendentry{\(x^2 - 2x - 1\)}


\end{axis}
\end{tikzpicture}
\caption{graph in figure enviroment}
\label{fig:pm}
\end{figure}



\blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext


\end{document}

答案1

您可以尝试使用两个subfigure环境,并将其宽度设置为\columnwidth,并在\hfill它们之间使用。注意,我还使用了\columnwidth尺寸axis

关于您的最后一个问题,您是否在寻找scale only axis选项?即,使用\begin{axis}[scale only axis, width=5cm],5cm 单独确定轴框的大小,无需标签。

\documentclass[twocolumn,10pt]{article}

\usepackage{blindtext}
\usepackage{subcaption}
\usepackage{pgfplots}


\begin{document}

\begin{figure*}[!h]
\begin{subfigure}{\columnwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.8\columnwidth,
    height=0.6\columnwidth,
]

\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]{x^2 - 2*x - 1};
\addlegendentry{\(x^2 - 2x - 1\)}
\end{axis}
\end{tikzpicture}
\caption{Graph A}
\end{subfigure}
\hfill
\begin{subfigure}{\columnwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.8\columnwidth,
    height=0.6\columnwidth,
]

\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]{x^2 - 2*x - 1};
\addlegendentry{\(x^2 - 2x - 1\)}
\end{axis}
\end{tikzpicture}
\caption{graph B}
\label{fig:totalTemperatureAmp}
\end{subfigure}
\caption{graph in subfloat enviroment}
\label{fig:amplitudeBC}
\end{figure*}


\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.8\columnwidth,
    height=0.6\columnwidth,
]

\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]{x^2 - 2*x - 1};
\addlegendentry{\(x^2 - 2x - 1\)}


\end{axis}
\end{tikzpicture}
\caption{graph in figure enviroment}
\label{fig:pm}
\end{figure}



\blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext \blindtext


\end{document}

相关内容