working on groups and iris notebook
This commit is contained in:
parent
fcfcc9a94a
commit
431d60a58a
File diff suppressed because one or more lines are too long
19
src/args.jl
19
src/args.jl
@ -260,7 +260,8 @@ type GroupBy
|
||||
end
|
||||
|
||||
|
||||
function extractGroupArgs(v::AVec)
|
||||
# this is when given a vector-type of values to group by
|
||||
function extractGroupArgs(v::AVec, d::Dict)
|
||||
groupLabels = sort(collect(unique(v)))
|
||||
n = length(groupLabels)
|
||||
if n > 20
|
||||
@ -272,13 +273,23 @@ end
|
||||
|
||||
|
||||
# expecting a mapping of "group label" to "group indices"
|
||||
function extractGroupArgs{T, V<:AVec{Int}}(d::Dict{T,V})
|
||||
groupLabels = sortedkeys(d)
|
||||
groupIds = VecI[collect(d[k]) for k in groupLabels]
|
||||
function extractGroupArgs{T, V<:AVec{Int}}(idxmap::Dict{T,V}, d::Dict)
|
||||
groupLabels = sortedkeys(idxmap)
|
||||
groupIds = VecI[collect(idxmap[k]) for k in groupLabels]
|
||||
GroupBy(groupLabels, groupIds)
|
||||
end
|
||||
|
||||
|
||||
# expecting the column name of a dataframe that was passed in... anything else should error
|
||||
function extractGroupArgs(s::Symbol, d::Dict)
|
||||
if haskey(d, :dataframe) && haskey(d[:dataframe], s)
|
||||
return extractGroupArgs(d[:dataframe][s])
|
||||
else
|
||||
error("Got a symbol, and expected that to be a key in d[:dataframe]. s=$s d=$d")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
function warnOnUnsupportedArgs(pkg::PlottingPackage, d::Dict)
|
||||
|
||||
@ -134,7 +134,7 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
||||
# line_style = line_style)
|
||||
push!(gfargs, theme)
|
||||
|
||||
# first things first... lets so the sticks hack
|
||||
# first things first... lets do the sticks hack
|
||||
if d[:linetype] == :sticks
|
||||
d, dScatter = sticksHack(;d...)
|
||||
|
||||
@ -177,8 +177,14 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
||||
|
||||
# add to the legend
|
||||
if length(gplt.guides) > 0 && isa(gplt.guides[1], Gadfly.Guide.ManualColorKey)
|
||||
|
||||
# TODO: there's a BUG in gadfly if you pass in the same color more than once,
|
||||
# since gadfly will call unique(colors), but doesn't also merge the rows that match
|
||||
# Should ensure from this side that colors which are the same are merged together
|
||||
|
||||
push!(gplt.guides[1].labels, d[:label])
|
||||
push!(gplt.guides[1].colors, d[:marker] == :none ? d[:color] : d[:markercolor])
|
||||
# println("updated legend: ", gplt.guides)
|
||||
end
|
||||
|
||||
# for histograms, set x=y
|
||||
|
||||
20
src/plot.jl
20
src/plot.jl
@ -88,8 +88,8 @@ function plot!(plt::Plot, args...; kw...)
|
||||
# index partitions/filters to be passed through to the next step.
|
||||
# Ideally we don't change the insides ot createKWargsList too much to
|
||||
# save from code repetition. We could consider adding a throw
|
||||
groupargs = haskey(d, :group) ? [extractGroupArgs(d[:group])] : []
|
||||
@show groupargs
|
||||
groupargs = haskey(d, :group) ? [extractGroupArgs(d[:group], d)] : []
|
||||
# @show groupargs
|
||||
|
||||
# just in case the backend needs to set up the plot (make it current or something)
|
||||
preparePlotUpdate(plt)
|
||||
@ -105,10 +105,11 @@ function plot!(plt::Plot, args...; kw...)
|
||||
# now we can plot the series
|
||||
for (i,di) in enumerate(kwList)
|
||||
plt.n += 1
|
||||
# println("Plotting: ", di)
|
||||
plot!(plt.plotter, plt; di...)
|
||||
end
|
||||
|
||||
#
|
||||
# add title, axis labels, ticks, etc
|
||||
updatePlotItems(plt, d)
|
||||
currentPlot!(plt)
|
||||
|
||||
@ -205,10 +206,16 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
||||
end
|
||||
|
||||
# build the series arg dict
|
||||
n = plt.n + i
|
||||
n = plt.n + i + get(d, :numUncounted, 0)
|
||||
d = getSeriesArgs(plt.plotter, getinitargs(plt, n), d, i, convertSeriesIndex(plt, n), n)
|
||||
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
||||
|
||||
if haskey(d, :idxfilter)
|
||||
# @show d[:idxfilter] d[:x] d[:y]
|
||||
d[:x] = d[:x][d[:idxfilter]]
|
||||
d[:y] = d[:y][d[:idxfilter]]
|
||||
end
|
||||
|
||||
# for linetype `line`, need to sort by x values
|
||||
if d[:linetype] == :line
|
||||
# order by x
|
||||
@ -230,7 +237,10 @@ 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)
|
||||
kwlist, xmeta, ymeta = createKWargsList(plt, args...; kw...,
|
||||
idxfilter = groupby.groupIds[i],
|
||||
label = string(glab),
|
||||
numUncounted = length(ret)) # we count the idx from plt.n + numUncounted + i
|
||||
append!(ret, kwlist)
|
||||
end
|
||||
ret, nothing, nothing # TODO: handle passing meta through
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user