# Multiple legends for barCharts

I came across this and found it quite cool.

Here is the minimal example:

 Plot3D[
Re[Sin[x + I y]],
{x, -2 Pi, Pi},
{y, -2 Pi, 2 Pi},
PlotLegends -> {
Placed[BarLegend[Automatic, LabelStyle -> {14, GrayLevel[0.3]}], Right],
Placed[BarLegend[Automatic, LabelStyle -> {14, GrayLevel[0.3]}], Top]
}
]


I want to do the same for a BarChart and do the equivalent of:

BarChart[
{1,2,10,20},
ChartStyle -> {Red,Blue, Darker[Red], Darker[Blue]},
ChartLegends-> {
Placed[{"One", "Two"}, Top],
Placed[{"One", "Two", "Ten", "Twenty"}, Left]
}
]


However the above simply gives me one legend with the last set of values. what am I missing? is there an elegant way of getting it to work?

One possible way is to use two datasets as input:

BarChart[{{1, 2, 10, 20}, {}},
ChartStyle -> {Red, Blue, Darker[Red], Darker[Blue]},
ChartLegends ->
{Placed[SwatchLegend[{Red, Blue}, {"One", "Two"}], Top],
Placed[{"One", "Two", "Ten", "Twenty"}, Left]}]


Another way is to wrap input data with Legended

BarChart[MapThread[Legended[#, Placed[#2, Left]] &,
{{1, 2, 10, 20}, {"One", "Two", "Ten", "Twenty"}}],
ChartStyle -> {Red, Blue, Darker[Red], Darker[Blue]},
ChartLegends -> Placed[{"One", "Two"}, Top]]


Use ChartStyle -> "Rainbow" to get

The first method requires manual insertion of appropriate colors in the first SwatchLegend to get the same picture, i.e., to use

 ChartLegends -> {Placed[SwatchLegend[ColorData[{"Rainbow",{1,4}}]/@{1,2},
{"One", "Two"}], Top],
Placed[{"One", "Two", "Ten", "Twenty"}, Left]}