Stacked bar graphs

In Gadfly:

import Cairo
using DataFrames, Gadfly, RDatasets
D = dataset("datasets","HairEyeColor")
palette = ["brown","blue","tan","green"]

p = plot(D, x=:Sex, y=:Freq, color=:Eye, xgroup=:Hair,
    Geom.subplot_grid(Geom.bar(position=:stack)),
    Scale.color_discrete_manual(palette...), 
    Guide.xlabel("Hair color"))

# draw(PNG("haireyecolor.png", 6.6inch, 4inch), p)
draw(PNG(6.6inch, 4inch), p)

haireyecolor

For more Gadfly, see the plot gallery.

2 Likes