1

I am trying to create a global legend for the bar plots. My current attempt looks like the following, is there any way to change the colors to the corresponding colors in the plot and symbols to bar plot symbols in the global legend?

Also how can I center my caption in each figure? Currently it seems like all of my captions are aligned to the left

Here is my LaTeX code:

\begin{figure}[H]
\begin{minipage}{0.49\textwidth}
    \resizebox{\textwidth}{!}{%
    \begin{tikzpicture}[baseline]
        \begin{axis}[
        ybar,
        bar width=0.1cm,
        width= 7.4cm,
        xtick=data,
        symbolic x coords = {Base, Random, Unequal, Imbalanced}
        ]
    \addplot+[bar shift=0cm, forget plot] coordinates {(Base, 0.702)};
    \addplot coordinates {(Random, 0.677) (Unequal, 0.699) (Imbalanced, 0.687)};
    \addplot coordinates {(Random, 0.684) (Unequal, 0.665) (Imbalanced, 0.64)};
    \addplot coordinates {(Random, 0.679) (Unequal, 0.67) (Imbalanced, 0.611)};
    \addplot coordinates {(Random, 0.691) (Unequal, 0.69) (Imbalanced, 0.672)};
    \addplot coordinates {(Random, 0.706) (Unequal, 0.706) (Imbalanced, 0.703)};

    \end{axis}
\end{tikzpicture}
}
\caption{Heart Failure F1-Scores}\label{fig7}

\end{minipage}% \begin{minipage}{0.49\textwidth} \resizebox{\textwidth}{!}{% \begin{tikzpicture}[baseline] \begin{axis}[ ybar, bar width=0.1cm, width=7.4cm, xtick=data, symbolic x coords = {Base, Random, Unequal, Imbalanced} ]

    \addplot+[bar shift=0cm, forget plot] coordinates {(Base, 0.922)};
    \addplot coordinates {(Random, 0.891) (Unequal, 0.902) (Imbalanced, 0.893)};
    \addplot coordinates {(Random, 0.895) (Unequal, 0.888) (Imbalanced, 0.885)};
    \addplot coordinates {(Random, 0.893) (Unequal, 0.877) (Imbalanced, 0.883)};
    \addplot coordinates {(Random, 0.921) (Unequal, 0.915) (Imbalanced, 0.914)};
    \addplot coordinates {(Random, 0.922) (Unequal, 0.918) (Imbalanced, 0.919)};

    \end{axis}
\end{tikzpicture}
}
\caption{Heart Failure AUC-ROC}\label{fig8}

\end{minipage}%

\begin{tikzpicture} \begin{axis}[ legend columns=5, legend style={% at={(-100,-100)},% anchor=north east,% at={(axis description cs:1,10),% },% /tikz/column 2/.style={column sep=5pt,},},] \addplot {0}; \addlegendentry{Local 1} \addplot {0}; \addlegendentry{Local 2} \addplot {0}; \addlegendentry{Local 3} \addplot {0}; \addlegendentry{Random Merge} \addplot {0}; \addlegendentry{Weighted Merge} \end{axis} \end{tikzpicture} \end{figure}

0 Answers0