You could create a function which, given a symbol, generates the layer for 
you:

```
getlayer(s) = layer(x=:x, y=s, Geom.line)
```

Next, you can use this function to get the layers you need:

```
plot(df, getlayer(:y1), getlayer(:y2), Guide.xlabel("k"))
# equivalently:
plot(df, layer(x=:x, y=:y1, Geom.line), layer(x=:x, y=:y2, Geom.line), 
Guide.xlabel("k"))
```

If you have all the symbols you want to iterate over (check out the `names` 
function...) you can use

```
plot(df, [getlayer(s) for s in symbols]..., Guide.xlabel("k"))
```

But a warning: this will probably be slow if you have many columns. It will 
almost certainly be very slow with hundreds of them. (On the other hand, I 
imagine the plot will be pretty hard to read with hundreds of lines...)

// T


On Monday, June 23, 2014 9:23:13 PM UTC+2, Leandro Seixas wrote:
>
> Hello,
>
> I am trying to do graphs with multiple layers with Gadfly. I have a 
> dataframe with many columns, one "x" and a lot of "y"s, and I want to plot 
> this in a single graph.
>
> For two layers, I have the following:
>
> plot(df, layer(x="x", y=df[2], Geom.line), layer(x="x", y=df[3], 
> Geom.line), Guide.xlabel("k")),
>
>
> but if my dataframe has *dozens* or *hundreds* columns, what I should do 
> to plot this in a single graph?
>
> Best,
>
> Leandro.
>

Reply via email to