various fixes
This commit is contained in:
parent
7dfcbabe0c
commit
027961bffa
6
examples/meetup/slides_20151028.ipynb
Normal file
6
examples/meetup/slides_20151028.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@ -154,6 +154,7 @@ _plotDefaults[:link] = false
|
|||||||
_plotDefaults[:linkx] = false
|
_plotDefaults[:linkx] = false
|
||||||
_plotDefaults[:linky] = false
|
_plotDefaults[:linky] = false
|
||||||
_plotDefaults[:linkfunc] = nothing
|
_plotDefaults[:linkfunc] = nothing
|
||||||
|
# _plotDefaults[:dataframe] = nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -85,9 +85,17 @@ function createGadflyPlotObject(d::Dict)
|
|||||||
unshift!(gplt.guides, Gadfly.Guide.manual_color_key("", @compat(AbstractString)[], Color[]))
|
unshift!(gplt.guides, Gadfly.Guide.manual_color_key("", @compat(AbstractString)[], Color[]))
|
||||||
end
|
end
|
||||||
|
|
||||||
gplt.theme = Gadfly.Theme(
|
# hide the legend
|
||||||
|
if get(d, :legend, true)
|
||||||
|
extra_theme_args = Any[]
|
||||||
|
else
|
||||||
|
extra_theme_args = Any[(:key_position, :none)]
|
||||||
|
end
|
||||||
|
|
||||||
|
gplt.theme = Gadfly.Theme(;
|
||||||
background_color = getColor(d[:background_color]),
|
background_color = getColor(d[:background_color]),
|
||||||
plot_padding = 1 * Gadfly.mm,
|
plot_padding = 1 * Gadfly.mm,
|
||||||
|
extra_theme_args...
|
||||||
)
|
)
|
||||||
gplt
|
gplt
|
||||||
end
|
end
|
||||||
@ -154,7 +162,7 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
|||||||
# if my PR isn't present, don't set the line_style
|
# if my PR isn't present, don't set the line_style
|
||||||
local extra_theme_args
|
local extra_theme_args
|
||||||
try
|
try
|
||||||
extra_theme_args = [(:line_style, Gadfly.get_stroke_vector(d[:linestyle]))]
|
extra_theme_args = Any[(:line_style, Gadfly.get_stroke_vector(d[:linestyle]))]
|
||||||
catch
|
catch
|
||||||
extra_theme_args = Any[]
|
extra_theme_args = Any[]
|
||||||
end
|
end
|
||||||
|
|||||||
13
src/plot.jl
13
src/plot.jl
@ -89,6 +89,13 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
warnOnUnsupportedArgs(plt.backend, d)
|
warnOnUnsupportedArgs(plt.backend, d)
|
||||||
|
|
||||||
# handle a "group by" mechanism.
|
# handle a "group by" mechanism.
|
||||||
|
# group = get(d, :group, nothing)
|
||||||
|
# if group == nothing
|
||||||
|
# groupargs = []
|
||||||
|
# else
|
||||||
|
# if haskey(d, :subplot)
|
||||||
|
# groupargs = extractGroupArgs(group, d[:dataframe])
|
||||||
|
# end
|
||||||
groupargs = get(d, :group, nothing) == nothing ? [] : [extractGroupArgs(d[:group], args...)]
|
groupargs = get(d, :group, nothing) == nothing ? [] : [extractGroupArgs(d[:group], args...)]
|
||||||
|
|
||||||
# just in case the backend needs to set up the plot (make it current or something)
|
# just in case the backend needs to set up the plot (make it current or something)
|
||||||
@ -274,7 +281,6 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
|||||||
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
||||||
|
|
||||||
if haskey(d, :idxfilter)
|
if haskey(d, :idxfilter)
|
||||||
# @show d[:idxfilter] d[:x] d[:y]
|
|
||||||
d[:x] = d[:x][d[:idxfilter]]
|
d[:x] = d[:x][d[:idxfilter]]
|
||||||
d[:y] = d[:y][d[:idxfilter]]
|
d[:y] = d[:y][d[:idxfilter]]
|
||||||
end
|
end
|
||||||
@ -288,6 +294,11 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
|||||||
d[:linetype] = :path
|
d[:linetype] = :path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# cleanup those fields that were used only for generating kw args
|
||||||
|
for k in (:idxfilter, :numUncounted, :dataframe)
|
||||||
|
delete!(d, k)
|
||||||
|
end
|
||||||
|
|
||||||
# add it to our series list
|
# add it to our series list
|
||||||
push!(ret, d)
|
push!(ret, d)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -62,6 +62,7 @@ function corrplot{T<:Real,S<:Real}(mat::AMat{T}, corrmat::AMat{S} = cor(mat);
|
|||||||
colors = :redsblues,
|
colors = :redsblues,
|
||||||
labels = nothing, kw...)
|
labels = nothing, kw...)
|
||||||
m = size(mat,2)
|
m = size(mat,2)
|
||||||
|
means = mean(mat, 1)
|
||||||
|
|
||||||
# might be a mistake?
|
# might be a mistake?
|
||||||
@assert m <= 20
|
@assert m <= 20
|
||||||
@ -80,6 +81,10 @@ function corrplot{T<:Real,S<:Real}(mat::AMat{T}, corrmat::AMat{S} = cor(mat);
|
|||||||
# histogram on diagonal
|
# histogram on diagonal
|
||||||
histogram!(plt, mat[:,i], c=:black, leg=false)
|
histogram!(plt, mat[:,i], c=:black, leg=false)
|
||||||
i > 1 && plot!(plt, yticks = :none)
|
i > 1 && plot!(plt, yticks = :none)
|
||||||
|
elseif i < j
|
||||||
|
# plot!(plt, mat[:,j], mat[:,i], l=:hexbin, leg=false)
|
||||||
|
# plot!(plt, [0], [0], ann=(0, 0, "Corr:\n$(corrmat[i,j])"), leg=false)
|
||||||
|
plot!(plt, [means[j]], [means[i]], title = @sprintf("Corr:\n%0.3f", corrmat[i,j]), yticks=:none)
|
||||||
else
|
else
|
||||||
# scatter plots off-diagonal, color determined by correlation
|
# scatter plots off-diagonal, color determined by correlation
|
||||||
c = RGBA(RGB(getColorZ(cgrad, corrmat[i,j])), 0.3)
|
c = RGBA(RGB(getColorZ(cgrad, corrmat[i,j])), 0.3)
|
||||||
|
|||||||
@ -230,16 +230,32 @@ function subplot!(subplt::Subplot, args...; kw...)
|
|||||||
subplt.initialized = buildSubplotObject!(subplt, true)
|
subplt.initialized = buildSubplotObject!(subplt, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
kwList, xmeta, ymeta = createKWargsList(subplt, args...; d...)
|
# handle grouping
|
||||||
|
group = get(d, :group, nothing)
|
||||||
|
if group == nothing
|
||||||
|
groupargs = []
|
||||||
|
else
|
||||||
|
groupargs = [extractGroupArgs(d[:group], args...)]
|
||||||
|
delete!(d, :group)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
kwList, xmeta, ymeta = createKWargsList(subplt, groupargs..., args...; d...)
|
||||||
|
|
||||||
# TODO: something useful with meta info?
|
# TODO: something useful with meta info?
|
||||||
|
|
||||||
for (i,di) in enumerate(kwList)
|
for (i,di) in enumerate(kwList)
|
||||||
|
|
||||||
subplt.n += 1
|
subplt.n += 1
|
||||||
plt = getplot(subplt) # get the Plot object where this series will be drawn
|
plt = getplot(subplt)
|
||||||
|
|
||||||
|
# cleanup the dictionary that we pass into the plot! command
|
||||||
di[:show] = false
|
di[:show] = false
|
||||||
haskey(d, :dataframe) && delete!(d, :dataframe)
|
di[:subplot] = true
|
||||||
|
for k in (:title, :xlabel, :xticks, :xlims, :xscale, :xflip,
|
||||||
|
:ylabel, :yticks, :ylims, :yscale, :yflip)
|
||||||
|
delete!(di, k)
|
||||||
|
end
|
||||||
dumpdict(di, "subplot! kwList $i")
|
dumpdict(di, "subplot! kwList $i")
|
||||||
|
|
||||||
plot!(plt; di...)
|
plot!(plt; di...)
|
||||||
@ -258,6 +274,9 @@ function subplot!(subplt::Subplot, args...; kw...)
|
|||||||
for (k,v) in di
|
for (k,v) in di
|
||||||
if typeof(v) <: AVec
|
if typeof(v) <: AVec
|
||||||
di[k] = v[mod1(i, length(v))]
|
di[k] = v[mod1(i, length(v))]
|
||||||
|
elseif typeof(v) <: AMat
|
||||||
|
m = size(v,2)
|
||||||
|
di[k] = (size(v,1) == 1 ? v[1, mod1(i, m)] : v[:, mod1(i, m)])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
dumpdict(di, "Updating sp $i")
|
dumpdict(di, "Updating sp $i")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user