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[:linky] = false
|
||||
_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[]))
|
||||
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]),
|
||||
plot_padding = 1 * Gadfly.mm,
|
||||
extra_theme_args...
|
||||
)
|
||||
gplt
|
||||
end
|
||||
@ -154,7 +162,7 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
||||
# if my PR isn't present, don't set the line_style
|
||||
local extra_theme_args
|
||||
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
|
||||
extra_theme_args = Any[]
|
||||
end
|
||||
|
||||
13
src/plot.jl
13
src/plot.jl
@ -89,6 +89,13 @@ function plot!(plt::Plot, args...; kw...)
|
||||
warnOnUnsupportedArgs(plt.backend, d)
|
||||
|
||||
# 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...)]
|
||||
|
||||
# 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)])
|
||||
|
||||
if haskey(d, :idxfilter)
|
||||
# @show d[:idxfilter] d[:x] d[:y]
|
||||
d[:x] = d[:x][d[:idxfilter]]
|
||||
d[:y] = d[:y][d[:idxfilter]]
|
||||
end
|
||||
@ -288,6 +294,11 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
||||
d[:linetype] = :path
|
||||
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
|
||||
push!(ret, d)
|
||||
end
|
||||
|
||||
@ -62,6 +62,7 @@ function corrplot{T<:Real,S<:Real}(mat::AMat{T}, corrmat::AMat{S} = cor(mat);
|
||||
colors = :redsblues,
|
||||
labels = nothing, kw...)
|
||||
m = size(mat,2)
|
||||
means = mean(mat, 1)
|
||||
|
||||
# might be a mistake?
|
||||
@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!(plt, mat[:,i], c=:black, leg=false)
|
||||
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
|
||||
# scatter plots off-diagonal, color determined by correlation
|
||||
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)
|
||||
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?
|
||||
|
||||
for (i,di) in enumerate(kwList)
|
||||
|
||||
|
||||
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
|
||||
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")
|
||||
|
||||
plot!(plt; di...)
|
||||
@ -258,6 +274,9 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
for (k,v) in di
|
||||
if typeof(v) <: AVec
|
||||
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
|
||||
dumpdict(di, "Updating sp $i")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user