I’m assuming I’m just missing something, but I can’t find how to do this in the docs.
Say I have a plot from the following data
using DataFrames, Gadfly, Distributions
# make some data
x = range(0, 2π, length=100)
y1 = @. sin(x) + 0.01 * randn()
y2 = @. cos(x) + 0.01 * randn()
x = vcat(x,x)
y = vcat(y1,y2)
# string-based categorical variable
func = vcat(repeat(["sin"], 100), repeat(["cos"], 100))
# make dataframe
df = DataFrame(
hcat(x,y,func),
[:x,:y,:func]
)
df[!, 1] = convert.(Float64, df[:, 1]) # there's probably a better way to do this....
df[!, 2] = convert.(Float64, df[:, 2])
df[!, 3] = convert.(String, df[:, 3])
# add the upper and lower bounds for the ribbon
df.ymax = df.y .+ rand(Uniform(0.3,0.7), 200)
df.ymin = df.y .- rand(Uniform(0.3,0.7), 200)
And I want to plot a line with a ribbon. I can do that no problem with this:
plot(df, x=:x,y=:y,
ymax = :ymax, ymin = :ymin, alpha = [0.2],
color = :func,
Geom.line, Geom.ribbon)
which produces this:
But I want to specify which colors to use, which I think I am supposed to do via the Guide.manual_color_key
, and that would ideally also let me rename the legend items, so I figured it would work something like this
plot(df, x=:x,y=:y,
ymax = :ymax, ymin = :ymin, alpha = [0.2],
color = :func,
Geom.line, Geom.ribbon,
Guide.manual_color_key("Function",["sin","cos"],
["#3b3759", "#cf8da7"]))
but that produces this:
I want both the ribbons and the lines to reflect the specified colors - how should I re-state that?