If you map fill
to Type
, and alpha
to the density, you get more or less what you want:
ggplot(dz, aes(x = Costs, y = 1, fill=Type)) +
stat_density(aes(alpha=..density..), geom = "tile", position = "identity") +
scale_fill_manual(values=c("red", "blue"))