fixed subplot bug

This commit is contained in:
Thomas Breloff 2015-09-19 00:38:50 -04:00
parent f5a6f129dd
commit 6aa56fd30f
3 changed files with 10 additions and 17 deletions

View File

@ -185,16 +185,12 @@ function plot!(pkg::PyPlotPackage, plt::Plot; kw...)
extraargs[:label] = d[:label] extraargs[:label] = d[:label]
# do the plot # do the plot
# @show lt
if lt == :hist if lt == :hist
d[:serieshandle] = plotfunc(d[:y]; extraargs...)[1] d[:serieshandle] = plotfunc(d[:y]; extraargs...)[1]
elseif lt in (:scatter, :heatmap, :hexbin) elseif lt in (:scatter, :heatmap, :hexbin)
d[:serieshandle] = plotfunc(d[:x], d[:y]; extraargs...) d[:serieshandle] = plotfunc(d[:x], d[:y]; extraargs...)
else else
d[:serieshandle] = plotfunc(d[:x], d[:y]; extraargs...)[1] d[:serieshandle] = plotfunc(d[:x], d[:y]; extraargs...)[1]
# retval = plotfunc(d[:x], d[:y]; extraargs...)
# @show retval
# d[:serieshandle] = retval
end end
# this sets the bg color inside the grid (plt.o.o == matplotlib.Figure) # this sets the bg color inside the grid (plt.o.o == matplotlib.Figure)

View File

@ -198,7 +198,7 @@ function createKWargsList{T<:Real}(plt::PlottingObject, y::AMat{T}; kw...)
n,m = size(y) n,m = size(y)
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = 1:n d[:x] = 1:n
d[:y] = y[:,i] d[:y] = y[:,i]
push!(ret, d) push!(ret, d)
@ -212,7 +212,7 @@ function createKWargsList{T<:Real,S<:Real}(plt::PlottingObject, x::AVec{T}, y::A
@assert length(x) == n @assert length(x) == n
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = x d[:x] = x
d[:y] = y[:,i] d[:y] = y[:,i]
push!(ret, d) push!(ret, d)
@ -226,7 +226,7 @@ function createKWargsList{T<:Real,S<:Real}(plt::PlottingObject, x::AMat{T}, y::A
n,m = size(y) n,m = size(y)
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = x[:,i] d[:x] = x[:,i]
d[:y] = y[:,i] d[:y] = y[:,i]
push!(ret, d) push!(ret, d)
@ -255,7 +255,7 @@ function createKWargsList(plt::PlottingObject, fs::Vector{Function}, xmin::Real,
width = plt.initargs[:size][1] width = plt.initargs[:size][1]
x = collect(linspace(xmin, xmax, width)) # we don't need more than the width x = collect(linspace(xmin, xmax, width)) # we don't need more than the width
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = x d[:x] = x
d[:y] = map(fs[i], x) d[:y] = map(fs[i], x)
push!(ret, d) push!(ret, d)
@ -287,7 +287,7 @@ function createKWargsList{T<:Real}(plt::PlottingObject, x::AMat{T}, f::Function;
n,m = size(x) n,m = size(x)
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = x[:,i] d[:x] = x[:,i]
d[:y] = map(f, d[:x]) d[:y] = map(f, d[:x])
push!(ret, d) push!(ret, d)
@ -307,7 +307,7 @@ function createKWargsList(plt::PlottingObject, y::AVec; kw...)
m = length(y) m = length(y)
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = 1:length(y[i]) d[:x] = 1:length(y[i])
d[:y] = y[i] d[:y] = y[i]
push!(ret, d) push!(ret, d)
@ -327,7 +327,7 @@ function createKWargsList{T<:Real}(plt::PlottingObject, x::AVec{T}, y::AVec; kw.
m = length(y) m = length(y)
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = x d[:x] = x
d[:y] = getyvec(x, y[i]) d[:y] = getyvec(x, y[i])
push!(ret, d) push!(ret, d)
@ -341,7 +341,7 @@ function createKWargsList{T<:Real}(plt::PlottingObject, x::AVec, y::AMat{T}; kw.
@assert length(x) == m @assert length(x) == m
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = x[i] d[:x] = x[i]
d[:y] = getyvec(x[i], y[:,i]) d[:y] = getyvec(x[i], y[:,i])
push!(ret, d) push!(ret, d)
@ -355,7 +355,7 @@ function createKWargsList(plt::PlottingObject, x::AVec, y::AVec; kw...)
m = length(y) m = length(y)
ret = [] ret = []
for i in 1:m for i in 1:m
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = x[i] d[:x] = x[i]
d[:y] = getyvec(x[i], y[i]) d[:y] = getyvec(x[i], y[i])
push!(ret, d) push!(ret, d)
@ -367,7 +367,7 @@ end
function createKWargsList(plt::PlottingObject, n::Integer; kw...) function createKWargsList(plt::PlottingObject, n::Integer; kw...)
ret = [] ret = []
for i in 1:n for i in 1:n
d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+1), kw, i, plt.n + i) d = getSeriesArgs(plt.plotter, getinitargs(plt, plt.n+i), kw, i, plt.n + i)
d[:x] = zeros(0) d[:x] = zeros(0)
d[:y] = zeros(0) d[:y] = zeros(0)
push!(ret, d) push!(ret, d)

View File

@ -117,18 +117,15 @@ function subplot!(subplt::Subplot, args...; kw...)
d = Dict(kw) d = Dict(kw)
replaceAliases!(d) replaceAliases!(d)
@show d
for k in keys(_plotDefaults) for k in keys(_plotDefaults)
delete!(d, k) delete!(d, k)
end end
@show d
kwList = createKWargsList(subplt, args...; d...) kwList = createKWargsList(subplt, args...; d...)
for (i,d) in enumerate(kwList) for (i,d) 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) # get the Plot object where this series will be drawn
d[:show] = false d[:show] = false
@show d
plot!(plt; d...) plot!(plt; d...)
end end