I think this will do the trick, if I understand what you're going for.

 
plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing1,color=:_type),
        
layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing2,color=:_type),
        Scale.discrete_color_manual("red", "green", "blue"))


On Friday, July 25, 2014 10:51:14 AM UTC-7, Leah Hanson wrote:
>
> Thank, that's very helpful. :)
>
> This is what worked:
> ~~~
>
> plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing1,color=:_type),
>               
> layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing2,color=:_type))
> ~~~
>
> However, now I'd like to color by layer instead of by :_type, since I want 
> the two layers of dots to be different colors.
>
> This does not work:
> ~~~
>
> plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing1,color="red"),
>               
> layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing2,color="blue"))
> ~~~
>
> I've also tried passing the color argument into Geom.point or 
> Geom.subplot_grid. I tried setting the value of color to be a 
> "Scale.discrete_color_manual", but the color aesthetic did not consider 
> that to be an appropriate type.
>
> How do assign per-layer colors?
>
> Thanks,
> Leah
>
>
> On Fri, Jul 25, 2014 at 12:34 PM, Johan Sigfrids <[email protected] 
> <javascript:>> wrote:
>
>> I think you might have to put the Geom.subplot_grid inside the layers.
>>
>>
>> On Friday, July 25, 2014 7:37:48 PM UTC+3, Leah Hanson wrote:
>>>
>>> I am trying to make a relatively complicated graph in Gadfly, and am 
>>> struggling.
>>>
>>> This is some sample data with the same structure as my data.
>>> ~~~
>>> julia> t = readtable("testdata.csv")
>>> 9x5 DataFrame
>>> |-------|---------|------|-------|--------|--------|
>>> | Row # | _type   | rank | speed | thing1 | thing2 |
>>> | 1     | "red"   | 1    | 10.0  | 0.0    | 0.0    |
>>> | 2     | "red"   | 2    | 11.1  | 0.1    | 0.2    |
>>> | 3     | "red"   | 3    | 12.4  | 0.3    | 0.0    |
>>> | 4     | "green" | 1    | 8.0   | 0.2    | 1.0    |
>>> | 5     | "green" | 2    | 7.0   | 0.1    | 0.5    |
>>> | 6     | "green" | 3    | 9.0   | 0.2    | 0.0    |
>>> | 7     | "blue"  | 1    | 1.0   | 1.0    | 1.0    |
>>> | 8     | "blue"  | 2    | 2.0   | 0.2    | 0.2    |
>>> | 9     | "blue"  | 3    | 3.0   | 0.1    | 0.1    |
>>> ~~~
>>>
>>> Currently, I am trying to make a plot with three rows; each row has a 
>>> plot with two layers. The rows are by :_type. The x-axis for everything is 
>>> :rank. The two layers should be scatterplots of :thing1 and :thing2.
>>>
>>> I have tried several variations, here is one of them:
>>> ~~~
>>> julia> plot(t,Geom.subplot_grid(Geom.point),ygroup=:_type,layer(x=:
>>> rank,y=:thing1),layer(x=:rank,y=:thing2))
>>> Error showing value of type Plot:
>>> ERROR: The following aesthetics are required by Geom.point but are not 
>>> defined: x, y
>>>
>>>  in error at error.jl:21
>>>  in assert_aesthetics_defined at /usr/local/google/home/
>>> lhanson/.julia/v0.3/Gadfly/src/aesthetics.jl:148
>>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>>> src/geom/point.jl:27
>>>  in render_prepared at /usr/local/google/home/
>>> lhanson/.julia/v0.3/Gadfly/src/Gadfly.jl:718
>>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>>> src/geom/subplot.jl:234
>>>  in render_prepared at /usr/local/google/home/
>>> lhanson/.julia/v0.3/Gadfly/src/Gadfly.jl:718
>>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>>> src/Gadfly.jl:673
>>>  in display at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>>> src/Gadfly.jl:922
>>>  in display at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>>> src/Gadfly.jl:837
>>>  in print_response at REPL.jl:140
>>>  in print_response at REPL.jl:125
>>>  in anonymous at REPL.jl:584
>>>  in run_interface at ./LineEdit.jl:1377
>>>  in run_frontend at ./REPL.jl:816
>>>  in run_repl at ./REPL.jl:170
>>>  in _start at ./client.jl:399
>>> ~~~
>>>
>>> How do I put layers inside a subplot?
>>>
>>> Thanks,
>>> Leah
>>>
>>
>

Reply via email to