我的图表在 x 轴上有两个刻度。我想在一页上显示 3 个图表并包含 y 轴标签。目前这还不够。是否可以将 x 刻度标记移得更近一些,这样图表就不会太宽?
代码:
\begin{figure}[tbp]
\centering
\begin{subfigure}{0.26\linewidth}
\caption{Average Playback Version}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\begin{axis}[
%x tick label style={/pgf/number format/1000 sep=},
xlabel=Available Bandwidth (Mbps),
xtick={0, 1},
xticklabels={Early, Late},
enlarge x limits=0.15,
enlarge y limits=upper,
legend style={at={(0.5,1.0)},anchor=north,legend columns=-1},
ybar,
bar width=5pt,
ymin=0,
]
\addplot
coordinates{(0,1.1666666666666667) (1,5)};
\addplot
coordinates{(0,2.8333333333333335) (1,5)};
\legend{0,1,2,3,4}
\end{axis}
\end{tikzpicture}
\end{center}
\end{subfigure}
\hfill
\begin{subfigure}{0.26\linewidth}
\caption{Playback Smoothness}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\begin{axis}[
%x tick label style={/pgf/number format/1000 sep=},
xlabel=Available Bandwidth (Mbps),
xtick={0, 1},
xticklabels={Early, Late},
enlarge x limits=0.15,
enlarge y limits=upper,
legend style={at={(0.5,1.0)},anchor=north,legend columns=-1},
ybar,
bar width=5pt,
ymin=0,
]
\addplot
coordinates{(0,0.4289845892077917) (1,1)};
\addplot
coordinates{(0,0.3173238794109962) (1,1)};
\legend{0,1,2,3,4}
\end{axis}
\end{tikzpicture}
\end{center}
\end{subfigure}
\hfill
\begin{subfigure}{0.26\linewidth}
\caption{Prefetching Overhead}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\begin{axis}[
%x tick label style={/pgf/number format/1000 sep=},
xlabel=Available Bandwidth (Mbps),
xtick={0, 1},
xticklabels={Early, Late},
enlarge x limits=0.15,
enlarge y limits=upper,
legend style={at={(0.5,1.0)},anchor=north,legend columns=-1},
ybar,
bar width=5pt,
ymin=0,
]
\addplot
coordinates{(0,0) (1,0.01747354295543597)};
\addplot
coordinates{(0,0) (1,0.025513165391867983)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{subfigure}
\caption{iPad: Long-Term Decreases 4 Mbps - 0.5 Mbps}
\end{figure}
答案1
使用环境x
选项axis
,您可以给出用作单位的维度。这里写的内容类似于
\begin{axis}[
%x tick label style={/pgf/number format/1000 sep=},
x=2cm,
enlarge x limits=0.5,
xlabel=Available Bandwidth (Mbps),
xtick={0, 1},
xticklabels={Early, Late},
enlarge y limits=upper,
legend style={at={(0.5,1.0)},anchor=north,legend columns=-1},
ybar,
bar width=5pt,
ymin=0,
]
给出更加平衡的结果。
如果你想全局设置这些尺寸,你可以使用
\pgfplotsset{width={<dimension>}, height={<dimension>}}