Oh, I see. I think the easiest way would be to rearrange the data with the 
melt function.


melt(t, [:_type, :rank, :speed]) makes a table like:

|-------|----------|-------|---------|------|-------|
| Row # | variable | value | _type   | rank | speed |
| 1     | thing1   | 0.0   | "red"   | 1    | 10.0  |
| 2     | thing1   | 0.1   | "red"   | 2    | 11.1  |
| 3     | thing1   | 0.3   | "red"   | 3    | 12.4  |
| 4     | thing1   | 0.2   | "green" | 1    | 8.0   |
| 5     | thing1   | 0.1   | "green" | 2    | 7.0   |
| 6     | thing1   | 0.2   | "green" | 3    | 9.0   |
| 7     | thing1   | 1.0   | "blue"  | 1    | 1.0   |
| 8     | thing1   | 0.2   | "blue"  | 2    | 2.0   |
| 9     | thing1   | 0.1   | "blue"  | 3    | 3.0   |
| 10    | thing2   | 0.0   | "red"   | 1    | 10.0  |
| 11    | thing2   | 0.2   | "red"   | 2    | 11.1  |
| 12    | thing2   | 0.0   | "red"   | 3    | 12.4  |
| 13    | thing2   | 1.0   | "green" | 1    | 8.0   |
| 14    | thing2   | 0.5   | "green" | 2    | 7.0   |
| 15    | thing2   | 0.0   | "green" | 3    | 9.0   |
| 16    | thing2   | 1.0   | "blue"  | 1    | 1.0   |
| 17    | thing2   | 0.2   | "blue"  | 2    | 2.0   |
| 18    | thing2   | 0.1   | "blue"  | 3    | 3.0   |

With which the plot can be simplified to:

plot(melt(t, [:_type, :rank, :speed]),
     ygroup=:_type, x=:rank, y=:value, color=:variable,
     Geom.subplot_grid(Geom.point),
     Scale.discrete_color_manual("purple", "orange"))



On Friday, July 25, 2014 12:05:02 PM UTC-7, Leah Hanson wrote:
>
> That's not quite it. I think the :_type values being color names is 
> confusing things. I don't want the dots to be colored by :_type.
>
> I would like dots for :thing1 to be in purple and the dots for :thing2 to 
> be in orange. So every dot in the first layer needs to be purple and every 
> data in the second layer needs to be orange.
>
> Thanks,
> Leah
>
>
> On Fri, Jul 25, 2014 at 1:36 PM, Daniel Jones <[email protected] 
> <javascript:>> wrote:
>
>>
>> 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]> 
>>> 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