Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I found the key bar width on page 82 in the manual.

However, when I use it:

! Package pgfkeys Error: I do not know the key '/pgfplots/bar width', to which you passed '5pt', and I am going to ignore it. Perhaps you misspelled it.

Is there something (hopefully not so obvious) that I missed?

MWE

\documentclass[
a4paper
]{scrartcl}

\usepackage{
amsmath,
tikz,
pgfplots,
pgfplotstable,
}

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepgfplotslibrary{groupplots}


\pgfplotstableread[col sep=comma]{
Process,ValueA,ValueB
1,66,70
2,66,40
3,24,20
4,52,60
5,64,30
6,12,10
}{\tableabcdef}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\begin{groupplot}[
group style={
    group size=2 by 1, %2 cols 1 rows
    horizontal sep=1cm,
    %horizontal sep=2.5cm,
%   vertical sep=2.25cm,
    ylabels at=edge left,
    yticklabels at=edge left,
},
%
width=5cm,
height=7cm,
%
xlabel={Force in N},
ylabel={Process \#},
%
xbar,
bar width=5pt,
%
ytick=data,
nodes near coords,
nodes near coords align={right}
]
\nextgroupplot
\addplot+ table [x=ValueA, y=Process] {\tableabcdef};
\nextgroupplot
\addplot+ table [x=ValueB, y=Process] {\tableabcdef};
\end{groupplot}
\end{tikzpicture}
\end{center}
\end{document}
share|improve this question

1 Answer 1

up vote 7 down vote accepted

Use

/pgf/bar width=5pt,% bar width

Additionally, I would add the options

xmin=0,% minimum x value
enlarge x limits={abs={1.5em},upper},% space for nodes near coords

enter image description here

Code:

\documentclass[margin=10pt]{standalone}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots,pgfplotstable}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.10}

\begin{filecontents*}{force-stats.txt}
Process,ValueA,ValueB
1,66,70
2,66,40
3,24,20
4,52,60
5,64,30
6,12,10
\end{filecontents*}
\pgfplotstableread[col sep=comma]{force-stats.txt}{\tableabcdef}

\begin{document}
\begin{tikzpicture}[font=\small]
  \begin{groupplot}[
      group style={
          group size=2 by 1, %2 cols 1 rows
          horizontal sep=1cm,
          %horizontal sep=2.5cm,
          %vertical sep=2.25cm,
          ylabels at=edge left,
          yticklabels at=edge left,
      },
      %
      width=5cm,
      height=7cm,
      %
      xlabel={Force in N},
      ylabel={Process \#},
      %
      xbar,
      /pgf/bar width=5pt,% bar width
      %
      xmin=0,% minimum x value
      enlarge x limits={abs={1.5em},upper},% space for nodes near coords
      %
      ytick=data,
      nodes near coords,
      nodes near coords align={right},
    ]
    \nextgroupplot
    \addplot+ table [x=ValueA, y=Process,col sep=comma] {\tableabcdef};
    \nextgroupplot
    \addplot+ table [x=ValueB, y=Process,col sep=comma] {\tableabcdef};
  \end{groupplot}
\end{tikzpicture}
\end{document}

Note that I have used filecontents* instead of filecontents.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.