Creating multi column legend in ggplot

Solution 1:

you must assign the guide to the correct aesthetic and you used fill:

guides(fill=guide_legend(ncol=2))

And you should take care of the warning with geom_bar