In Gadfly, I am trying to color horizontal lines based on data. But since color of Geom.hline is not an aesthetic, but only an argument, my approach fails. How can I pass color form the data to the color argument?
My attempt:
using DataFrames, Gadfly
test = DataFrame(y = [1,2], group = ["a", "b"])
p = plot(test, yintercept = :y, color=:group, Geom.hline)
Desired behavior:
Two horizontal lines with two different colors (colored by group).
Actual behavior:
Two horizontal lines with the same color, warning message The following aesthetics are mapped, but not used by any geometry: color.
You can pass a
colorargument toGeom.hlinerather than to theplotfunction. As an example:This gives me the following result:
In your case you would have to map your groups against colors