我创建了一个包含三组条形图/柱形图的(分组)条形图,但如果第一组和第二组条形图之间的间距比第二组和第三组条形图之间的间距稍大一些,那就太好了。我该如何实现这一点(即不规则的 x 轴缩放)?
更新:
好吧,多亏了 Jake,我终于成功解决了我的问题,但现在又出现了另一个问题。我的节点出了问题。这是我的代码,并附上了结果:
\documentclass{article}
\usepackage{filecontents}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{sansmath}
\usepackage{xcolor}
\definecolor{blue4a}{HTML}{4D79A3}
\definecolor{blue4b}{HTML}{5C8DBD}
\definecolor{blue4c}{HTML}{91ADD1}
\definecolor{blue4d}{HTML}{C3CFE2}
\begin{filecontents}{data.dat}
name 2011 2012 2013 2014
Girls 10 20 30 40
Boys 20 30 40 50
Overall 60 70 80 90
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
ylabel = Percentage,
label style = {font=\tiny\sffamily},
axis lines* = left,
tick align = outside,
tick label style = {font=\tiny\sansmath\sffamily},
x = 1.64cm,
y = 0.055cm,
ymin = 0,
ymax = 98,
ymajorgrids,
grid style = dashed,
ybar = 0.00cm,
bar width = 0.32cm,
nodes near coords,
every node near coord%
/.append style = {%
font = \tiny\sansmath\sffamily},
enlarge x limits=0.305,
x filter/.code={\pgfmathparse{#1+(#1==2)*0.25}},
xtick=data,
xticklabels from table={data.dat}{name},
xticklabel style={text height=2ex}
]
\addplot [fill=blue4a] table [x expr=\coordindex] {data.dat};
\addplot [fill=blue4b] table [x expr=\coordindex, y index=2] {data.dat};
\addplot [fill=blue4c] table [x expr=\coordindex, y index=3] {data.dat};
\addplot [fill=blue4d] table [x expr=\coordindex, y index=4] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}