``````using DataFrames, Gadfly

set_default_plot_size(24cm, 10cm)

# 这个函数不用关注
function todf(data)
(m, n) = size(data)

X = [[] [] [] []]
for i in 1:m
X = vcat(X, hcat(algo, data[i, :], repeat([symb[i]], n), string.(data[i, :])))
end

return DataFrame(X, [:Algorithm, :Number, :Label, :Number_s])
end

algo = ["Algo1", "Algo2"]
symb = ["↑", "∼", "↓"]

data1 = [21 20
2 3
7 7]

data2 = [37 32
0 5
13 13]

df = vcat(
transform(todf(data1), AsTable(:) => ByRow((x)->3) => :Tasks),
transform(todf(data2), AsTable(:) => ByRow((x)->5) => :Tasks)
)

p1 = plot(df[df.Tasks .== 3,:], x=:Algorithm, y=:Number, color=:Label,
label=:Number_s,
Geom.label(position=:centered),
Stat.dodge(position=:stack),
Geom.bar(position=:stack),
Scale.x_discrete(levels = algo),
);

p2 = plot(df[df.Tasks .== 5,:], x=:Algorithm, y=:Number, color=:Label,
label=:Number_s,
Geom.label(position=:centered),
Stat.dodge(position=:stack),
Geom.bar(position=:stack),
Scale.x_discrete(levels = algo)
);

# 通过分组的形式画
Geom.subplot_grid(layer(
x=:Algorithm, y=:Number, color=:Label,
label=:Number_s,
Geom.label(position=:centered),
Geom.bar(position=:stack)
)),
Stat.dodge(position=:stack),
Scale.x_discrete(levels = algo)
);

hstack(p1, p2, p3)
``````