working on groups and iris notebook

This commit is contained in:
Thomas Breloff 2015-09-23 17:12:26 -04:00
parent e3612b973f
commit 870fb4e2df
3 changed files with 90 additions and 37 deletions

View File

@ -26,32 +26,14 @@
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
"INFO: Recompiling stale cache file /home/tom/.julia/lib/v0.4/Plots.ji for module Plots.\n",
"ERROR: LoadError: LoadError: UndefVarError: T not defined\n",
" in include at ./boot.jl:261\n",
" in include_from_node1 at ./loading.jl:304\n",
" in include at ./boot.jl:261\n",
" in include_from_node1 at ./loading.jl:304\n",
" [inlined code] from none:2\n",
" in anonymous at no file:0\n",
" in process_options at ./client.jl:284\n",
" in _start at ./client.jl:411\n",
"while loading /home/tom/.julia/v0.4/Plots/src/args.jl, in expression starting on line 265\n",
"while loading /home/tom/.julia/v0.4/Plots/src/Plots.jl, in expression starting on line 74\n"
"INFO: Recompiling stale cache file /home/tom/.julia/lib/v0.4/Plots.ji for module Plots.\n"
]
},
{
"ename": "LoadError",
"evalue": "LoadError: Failed to precompile Plots to /home/tom/.julia/lib/v0.4/Plots.ji\nwhile loading In[1], in expression starting on line 1",
"output_type": "error",
"traceback": [
"LoadError: Failed to precompile Plots to /home/tom/.julia/lib/v0.4/Plots.ji\nwhile loading In[1], in expression starting on line 1",
"",
" in error at ./error.jl:21",
" in recompile_stale at loading.jl:460",
" in _require_from_serialized at loading.jl:83",
" in _require_from_serialized at ./loading.jl:109",
" in require at ./loading.jl:219"
"name": "stdout",
"output_type": "stream",
"text": [
"[Plots.jl] Default backend: immerse"
]
}
],
@ -69,13 +51,22 @@
},
"outputs": [
{
"ename": "LoadError",
"evalue": "LoadError: UndefVarError: gadfly! not defined\nwhile loading In[2], in expression starting on line 1",
"output_type": "error",
"traceback": [
"LoadError: UndefVarError: gadfly! not defined\nwhile loading In[2], in expression starting on line 1",
""
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"[Plots.jl] Switched to backend: gadfly"
]
},
{
"data": {
"text/plain": [
"Plots.GadflyPackage()"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
@ -101,18 +92,38 @@
"in update! at /home/tom/.julia/v0.4/Nettle/src/hmac.jl:29\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"[Plots.jl] Initializing backend: gadfly\n",
"groupargs = Plots.GroupBy(UTF8String[\"setosa\",\"versicolor\",\"virginica\"],[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50],[51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100],[101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150]])"
]
},
{
"ename": "LoadError",
"evalue": "LoadError: UndefVarError: scatter not defined\nwhile loading In[3], in expression starting on line 1",
"evalue": "LoadError: MethodError: `start` has no method matching start(::Plots.GroupBy)\nwhile loading In[3], in expression starting on line 1",
"output_type": "error",
"traceback": [
"LoadError: UndefVarError: scatter not defined\nwhile loading In[3], in expression starting on line 1",
""
"LoadError: MethodError: `start` has no method matching start(::Plots.GroupBy)\nwhile loading In[3], in expression starting on line 1",
"",
" in append_any at essentials.jl:127",
" in plot! at /home/tom/.julia/v0.4/Plots/src/plot.jl:98",
" in plot at /home/tom/.julia/v0.4/Plots/src/plot.jl:58",
" in scatter at /home/tom/.julia/v0.4/Plots/src/Plots.jl:81"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"scatter(iris, :SepalLength, :SepalWidth)\n",
"scatter(iris, :SepalLength, :SepalWidth, group=iris[:Species])\n",
"plot!(u->6+2*sin(u), u->3+cos(u), 0, 2π, lab=\"an oval\", fill=3)\n",
"plot!(Any[[6],[3]], t=[:vline,:hline], w=4, c=RGB(1,0,0))\n",
"title!(\"Playing around with series\")"
@ -155,6 +166,28 @@
"scatter(iris, :SepalLength, [:PetalLength,:PetalWidth,:SepalWidth], m=:auto, ms=10, gui=false)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "LoadError",
"evalue": "LoadError: MethodError: `split` has no method matching split(::DataArrays.PooledDataArray{ASCIIString,UInt8,1})\nClosest candidates are:\n split(::Any, !Matched::Any, !Matched::Bool)\n split(::Any, !Matched::Any, !Matched::Integer)\n split(::Any, !Matched::Any, !Matched::Integer, !Matched::Bool)\nwhile loading In[7], in expression starting on line 2",
"output_type": "error",
"traceback": [
"LoadError: MethodError: `split` has no method matching split(::DataArrays.PooledDataArray{ASCIIString,UInt8,1})\nClosest candidates are:\n split(::Any, !Matched::Any, !Matched::Bool)\n split(::Any, !Matched::Any, !Matched::Integer)\n split(::Any, !Matched::Any, !Matched::Integer, !Matched::Bool)\nwhile loading In[7], in expression starting on line 2",
""
]
}
],
"source": [
"species = iris[:Species]\n",
"split(species)"
]
},
{
"cell_type": "code",
"execution_count": 29,

View File

@ -255,18 +255,27 @@ end
"A special type that will break up incoming data into groups, and allow for easier creation of grouped plots"
type GroupBy
numGroups::Int
groupLabels::Vector{UTF8String} # length == numGroups
groupIds::Vector{Vector{Int}} # list of indices for each group
end
function extractGroupArgs(v::AVec)
groupLabels = sort(collect(unique(v)))
n = length(groupLabels)
if n > 20
error("Too many group labels. n=$n Is that intended?")
end
groupIds = Vector{Int}[filter(i -> v[i] == glab, 1:length(v)) for glab in groupLabels]
GroupBy(groupLabels, groupIds)
end
# expecting a mapping of "group label" to "group indices"
function extractGroupArgs{V<:AVec{Int}}(d::Dict{T,V})
numGroups = length(d)
function extractGroupArgs{T, V<:AVec{Int}}(d::Dict{T,V})
groupLabels = sortedkeys(d)
groupIds = VecI[collect(d[k]) for k in groupLabels]
GroupBy(numGroups, groupLabels, groupIds)
GroupBy(groupLabels, groupIds)
end

View File

@ -225,6 +225,17 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
ret, xmeta, ymeta
end
# handle grouping
function createKWargsList(plt::PlottingObject, groupby::GroupBy, args...; kw...)
ret = []
for (i,glab) in enumerate(groupby.groupLabels)
# TODO: don't automatically overwrite labels
kwlist = createKWargsList(plt, args...; kw..., idxfilter = groupby.groupIds[i], label = glab)
append!(ret, kwlist)
end
ret, nothing, nothing # TODO: handle passing meta through
end
# pass it off to the x/y version
function createKWargsList(plt::PlottingObject, y; kw...)
createKWargsList(plt, nothing, y; kw...)