我不确定我哪里做错了,但在图中,x 轴上不应该有两个 32、两个 64 和两个 128。这是一个最低限度的工作示例;如能得到任何帮助,我将不胜感激。
\documentclass[table,xcolor=pdftex,dvipsnames]{beamer}
\usepackage{tikz}
\usepackage{tkz-graph}
\usepackage{pgfplots}
\begin{document}
\begin{frame}
\frametitle{How do systems perform...}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
title=XX Graph (42M vertices; 1.46B edges; size 12.5GB),
width = 11cm,
height = 6cm,
major x tick style = transparent,
ybar = 1pt,% configures `bar shift'
bar width=10pt,
ymin = 0,
ymax = 2500,
ymajorgrids = true,
legend style = {%
at = {(0.5,-0.3)},
anchor = north,
legend columns = -1},
ylabel = {Time (in sec)},
xlabel = {Scale},
symbolic x coords = {16,32,64,128},
ytick = {0,500,1000,1500,2000},
scaled y ticks = false,
]
\addplot coordinates {(16, 260.00) (32, 168.33) (64, 110.67) (128, 224.00) };
\addplot coordinates {(16, 575.50) (32, 278.80) (64, 259.25) (128, 233.69) };
\addplot coordinates {(16, 597.75) (32, 584.64) (64, 260.33) (128, 398.00) };
\addplot coordinates {(16, 411.00) (32, 373.00) (64, 143.00) (128, 168.33) };
\addplot coordinates {(16, 181) (32, 879.25) (64, 1200.67) (128, 1934) };
\small{\legend{A,B,C ,D ,E}}
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
答案1
您只需添加xtick=data
即可避免这种行为。
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title=XX Graph (42M vertices; 1.46B edges; size 12.5GB),
width=11cm,
height=6cm,
major x tick style=transparent,
ybar=1pt,% configures `bar shift'
bar width=10pt,
ymin=0,
ymax=2500,
ymajorgrids=true,
legend style={
at={(0.5,-0.3)},
anchor=north,
legend columns=-1},
ylabel={Time (in sec)},
xlabel={Scale},
ytick={0,500,1000,1500,2000},
scaled y ticks=false,
symbolic x coords = {16,32,64,128},
% this was the missing line
xtick=data,
% this is that the bars are not cutted at the end of the axis
enlarge x limits={0.2},
]
\addplot coordinates {(16, 260.00) (32, 168.33) (64, 110.67) (128, 224.00) };
\addplot coordinates {(16, 575.50) (32, 278.80) (64, 259.25) (128, 233.69) };
\addplot coordinates {(16, 597.75) (32, 584.64) (64, 260.33) (128, 398.00) };
\addplot coordinates {(16, 411.00) (32, 373.00) (64, 143.00) (128, 168.33) };
\addplot coordinates {(16, 181.00) (32, 879.25) (64, 1200.67) (128, 1934) };
\end{axis}
\end{tikzpicture}
\end{document}