I want to plot two bar plots with more space next to each other (now the yaxis label overlaps on first figure). Also I want to add x axis label and a caption for each figure. Can anyone help me to solve the problem? Code:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style={group size=2 by 1},width=12cm,height=8cm]
\nextgroupplot[
%legend style={at={(mygroup.south)},anchor=north,legend columns=-1},
symbolic x coords={Precision,Recall,F1-Score,Accuracy},
major tick length=0cm,
xtick=data,
ymin=50.0,
ylabel = {y},
xlabel = {x},
enlarge x limits=0.2,
enlarge y limits={upper,value=0.2},
nodes near coords,
ybar,
every node near coord/.append style={rotate=90, anchor=west},
bar width = 8pt,
]
\addplot coordinates {(Precision,86.6) (Recall,86.0) (F1-Score,86.3) (Accuracy,98.4)};
\addplot coordinates {(Precision,87.6) (Recall,86.2) (F1-Score,86.5) (Accuracy,97.5)};
\addplot coordinates {(Precision,85.9) (Recall,86.3) (F1-Score,86.1) (Accuracy,98.6)};
\addplot coordinates {(Precision,87.1) (Recall,86.8) (F1-Score,87.0) (Accuracy,99.2)};
\addplot coordinates {(Precision,85.5) (Recall,82.8) (F1-Score,83.7) (Accuracy,97.4)};
\addplot coordinates {(Precision,77.9) (Recall,77.7) (F1-Score,75.9) (Accuracy,87.8)};
%\legend{KNN,Neural Networks,Decision Tree,Random Forest,SVM,Naive Bayes}
\nextgroupplot[
legend style={at={(-\pgfkeysvalueof{/pgfplots/group/horizontal sep}/2,-0.1)},
anchor=north,legend columns=-1},
symbolic x coords={Precision,Recall,F1-Score,Accuracy},
major tick length=0cm,
xtick=data,
ymin=50.0,
ylabel = {y},
enlarge x limits=0.2,
enlarge y limits={upper,value=0.2},
nodes near coords,
ybar,
every node near coord/.append style={rotate=90, anchor=west},
bar width = 8pt,
]
\addplot coordinates {(Precision,86.6) (Recall,86.0) (F1-Score,86.3) (Accuracy,98.4)};
\addplot coordinates {(Precision,87.6) (Recall,86.2) (F1-Score,86.5) (Accuracy,97.5)};
\addplot coordinates {(Precision,85.9) (Recall,86.3) (F1-Score,86.1) (Accuracy,98.6)};
\addplot coordinates {(Precision,87.1) (Recall,86.8) (F1-Score,87.0) (Accuracy,99.2)};
\addplot coordinates {(Precision,85.5) (Recall,82.8) (F1-Score,83.7) (Accuracy,97.4)};
\addplot coordinates {(Precision,77.9) (Recall,77.7) (F1-Score,75.9) (Accuracy,87.8)};
\legend{KNN,Neural Networks,Decision Tree,Random Forest,SVM,Naive Bayes}
\end{groupplot}
\end{tikzpicture}
\end{document}



groupplotenvironment:group/horizontal sep=Xcm(initially 1cm). – Unknown May 28 '22 at 21:19