I'm trying to create a tikzpicture, composed of 2 separate diagrams. I'm using the \usepgfplotslibrary{groupplots} package for this. All is going fine, but I cannot seem to get the bars to a more central position (see image: they're currently at the very corners of the plot).
This is a minimal working example:
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage{tikz}
\usetikzlibrary{matrix}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={group size= 2 by 1},
height=8cm,
width=5cm,
ymax=100,
ymin=0,
ybar,
xtick=data,
x tick label style={rotate=45,anchor=east}
]
\nextgroupplot[title=A,legend to name=zelda, symbolic x coords={Class3, Class4}, bar width=9pt]
\addplot+[ybar, draw=red, fill=red] plot coordinates {
(Class3, 60.83)
(Class4, 54.83)
};
\addlegendentry{(Both) correct};
\addplot+[ybar, draw=blue, fill=blue] plot coordinates {
(Class3, 37.00)
(Class4, 42.17)
};
\addlegendentry{One correct};
\coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot
\nextgroupplot[title=B, symbolic x coords={Class1, Class2}, bar width=9pt]
\addplot+[ybar, draw=red, fill=red] plot coordinates {
(Class1,89.00)
(Class2,87.00)
};
\coordinate (bot) at (rel axis cs:1,0);% coordinate at bottom of the last plot
\end{groupplot}
\path (top)--(bot) coordinate[midway] (group center);
\node[above,rotate=90] at (group center -| current bounding box.west) {Accuracy};
\node[right=1em,inner sep=0pt] at(group center -| current bounding box.east {\pgfplotslegendfromname{zelda}};
\end{tikzpicture}
\end{document}
Any help would be highly appreciated.


enlargelimits=0.5which only showed an effect on the y-axis. Even better if it works without changing the symbolic coords! – Dreana Sep 03 '21 at 14:52