3

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}
7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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