在 pgfplots 中水平设置子图

在 pgfplots 中水平设置子图

图形是垂直绘制的,但我想将它们水平设置。请指导我可能的选项。

\documentclass[conference]{IEEEtran}
\ifCLASSINFOpdf
\else
\fi
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage[pdftex]{graphics}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{pgfplots}
\usepackage{subcaption}
\usepackage{pgfplotstable}
\usepackage{amsmath}
\usepgfplotslibrary{dateplot}
\usepackage{cite}
\usepackage{url}
\usepackage{amsbsy}
\usepgfplotslibrary{patchplots}
\pgfplotsset{compat=1.7}

\hyphenation{op-tical net-works semi-conduc-tor}
\begin{document}

\begin{figure}
\centering
\hspace{-2.15cm}
    \begin{subfigure}{.45\linewidth}
\begin{tikzpicture}
\begin{axis}[
    ylabel=Satisfied Requests,
    xlabel=Requests,
    height=5cm, width=8cm,
    legend cell align=left, legend columns=-1, legend style={inner xsep=2pt, inner ysep=2pt,at={(0.365,0.216)},anchor=east,font=\tiny},
    label style={font=\small},
    legend columns=1,
    xticklabel style={anchor=near xticklabel},
    ymin=0.2, ymax=0.6, ytick={0.1,0.2,0.3,0.4,0.5,0.6},
    xmin=0, xmax=1.1, xtick={0,0.2,0.4,0.6,0.8,1.0},
]
\addplot [thick,mark size=1.8pt,mark=square,red] table[x=x, y=y]   {a.txt};
%\addplot [thick,mark size=1.8pt,mark=asterisk,blue] table[x=x, y=y]  {Request vs. satisfied requests-2.txt};
%\addplot [thick,mark size=2.3pt,mark=diamond,black] table[x=x, y=y] {Request vs. satisfied requests-3.txt};
%\addplot [thick,mark size=1.8pt,mark=o,brown] table[x=x, y=y] {Request vs. satisfied requests-4.txt};
%\legend{Proactive high load, Proactive low load, Reactive low load, Reactive high load}
\end{axis}
\end{tikzpicture}
\subcaption{}
\end{subfigure}

\hspace{-2.05cm}
 \begin{subfigure}{.45\linewidth}
\begin{tikzpicture}
\begin{axis}[
    ylabel=Satisfied Requests,
    xlabel=Cache size,
    height=5cm, width=8cm,
    legend cell align=left, legend columns=-1, legend style={inner xsep=2pt, inner ysep=2pt,at={(0.996,0.21)},anchor=east,font=\tiny},
    label style={font=\small},
    legend columns=1,
    xticklabel style={anchor=near xticklabel},
    ymin=0, ymax=1.1, ytick={0,0.2,0.4,0.6,0.8,1.0},
    xmin=0, xmax=1.1, xtick={0,0.2,0.4,0.6,0.8,1.0},
]
\addplot [thick,mark size=1.8pt,mark=square,red] table[x=x, y=y]   {a.txt};
%\addplot [thick,mark size=1.8pt,mark=asterisk,blue] table[x=x, y=y]  {Cache vs. satisfied requests-2.txt};
%\addplot [thick,mark size=2.3pt,mark=diamond,black] table[x=x, y=y] {Cache vs. satisfied requests-3.txt};
%\addplot [thick,mark size=1.8pt,mark=o,brown] table[x=x, y=y] {Cache vs. satisfied requests-4.txt};
%\legend{Proactive high load, Proactive low load, Reactive low load, Reactive high load}
\end{axis}
\end{tikzpicture}
\subcaption{}
\end{subfigure}

\vspace{-0.08cm}
\caption{Simulation results for Proactive vs. Reactive caching with low and high load. (a) Hit radio vs. Number of requests (b) Hit radio vs. cache size}
\label{LQI-timex}
\end{figure}

\end{document} 

在此处输入图片描述

数据文件

x   y
0.1 0.53896
0.2 0.52122
0.3 0.50326
0.4 0.48145
0.5 0.45054
0.6 0.42319
0.7 0.40357
0.8 0.38396
0.9 0.36315
1   0.34668

答案1

子图的定位就像一个大字母,它们之间有一个空行,因此它们位于不同的段落中,一个在另一个之上。

您可以删除如下所示的段落分隔符,但图表的宽度大于文本宽度的一半,因此您需要使其更小,您需要选择缩放或显示较小的范围。

\documentclass[conference]{IEEEtran}
%???\ifCLASSINFOpdf \else \fi
%\hyphenation{op-tical net-works semi-conduc-tor}
%\usepackage[pdftex]{graphics}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{pgfplots}
\usepackage{subcaption}
\usepackage{pgfplotstable}
\usepackage{amsmath}
\usepgfplotslibrary{dateplot}
\usepackage{cite}
\usepackage{url}
\usepackage{amsbsy}
\usepgfplotslibrary{patchplots}
\pgfplotsset{compat=1.7}

% you have this twice but networks and semiconductor already the default
\hyphenation{op-tical net-works semi-conduc-tor}
\begin{document}

\begin{figure}
\centering

    \begin{subfigure}{.5\linewidth}
\begin{tikzpicture}
\begin{axis}[
    ylabel=Satisfied Requests,
    xlabel=Requests,
    height=5cm, width=8cm,
    legend cell align=left, legend columns=-1, legend style={inner xsep=2pt, inner ysep=2pt,at={(0.365,0.216)},anchor=east,font=\tiny},
    label style={font=\small},
    legend columns=1,
    xticklabel style={anchor=near xticklabel},
    ymin=0.2, ymax=0.6, ytick={0.1,0.2,0.3,0.4,0.5,0.6},
    xmin=0, xmax=1.1, xtick={0,0.2,0.4,0.6,0.8,1.0},
]
\addplot [thick,mark size=1.8pt,mark=square,red] table[x=x, y=y]   {a.txt};
%\addplot [thick,mark size=1.8pt,mark=asterisk,blue] table[x=x, y=y]  {Request vs. satisfied requests-2.txt};
%\addplot [thick,mark size=2.3pt,mark=diamond,black] table[x=x, y=y] {Request vs. satisfied requests-3.txt};
%\addplot [thick,mark size=1.8pt,mark=o,brown] table[x=x, y=y] {Request vs. satisfied requests-4.txt};
%\legend{Proactive high load, Proactive low load, Reactive low load, Reactive high load}
\end{axis}
\end{tikzpicture}
\subcaption{}
\end{subfigure}%
\hfill
 \begin{subfigure}{.5\linewidth}
\begin{tikzpicture}
\begin{axis}[
    ylabel=Satisfied Requests,
    xlabel=Cache size,
    height=5cm, width=8cm,
    legend cell align=left, legend columns=-1, legend style={inner xsep=2pt, inner ysep=2pt,at={(0.996,0.21)},anchor=east,font=\tiny},
    label style={font=\small},
    legend columns=1,
    xticklabel style={anchor=near xticklabel},
    ymin=0, ymax=1.1, ytick={0,0.2,0.4,0.6,0.8,1.0},
    xmin=0, xmax=1.1, xtick={0,0.2,0.4,0.6,0.8,1.0},
]
\addplot [thick,mark size=1.8pt,mark=square,red] table[x=x, y=y]   {a.txt};
%\addplot [thick,mark size=1.8pt,mark=asterisk,blue] table[x=x, y=y]  {Cache vs. satisfied requests-2.txt};
%\addplot [thick,mark size=2.3pt,mark=diamond,black] table[x=x, y=y] {Cache vs. satisfied requests-3.txt};
%\addplot [thick,mark size=1.8pt,mark=o,brown] table[x=x, y=y] {Cache vs. satisfied requests-4.txt};
%\legend{Proactive high load, Proactive low load, Reactive low load, Reactive high load}
\end{axis}
\end{tikzpicture}
\subcaption{}
\end{subfigure}

\vspace{-0.08cm}
\caption{Simulation results for Proactive vs. Reactive caching with low and high load. (a) Hit radio vs. Number of requests (b) Hit radio vs. cache size}
\label{LQI-timex}
\end{figure}

\end{document} 

相关内容