gr fixes and tests; fillrange convertToAnyVector

This commit is contained in:
Thomas Breloff 2016-04-28 12:51:08 -04:00
parent ce58f25488
commit d67aec6fec
6 changed files with 34 additions and 13 deletions

View File

@ -41,9 +41,10 @@ script:
- julia -e 'Pkg.clone(pwd()); Pkg.build("Plots")' - julia -e 'Pkg.clone(pwd()); Pkg.build("Plots")'
# - julia -e 'Pkg.clone("https://github.com/tbreloff/Images.jl.git"); Pkg.checkout("Images","tom_imgcompare");' # - julia -e 'Pkg.clone("https://github.com/tbreloff/Images.jl.git"); Pkg.checkout("Images","tom_imgcompare");'
# - julia -e 'Pkg.clone("Images"); Pkg.build("Images")' # - julia -e 'Pkg.clone("Images"); Pkg.build("Images")'
# - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")' - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")'
- julia -e 'Pkg.clone("https://github.com/tbreloff/ImageMagick.jl.git"); Pkg.checkout("ImageMagick","tb_write"); Pkg.build("ImageMagick")' - julia -e 'Pkg.clone("GR"); Pkg.build("GR")'
- julia -e 'Pkg.clone("https://github.com/tbreloff/VisualRegressionTests.jl.git");' # - julia -e 'Pkg.clone("https://github.com/tbreloff/ImageMagick.jl.git"); Pkg.checkout("ImageMagick","tb_write"); Pkg.build("ImageMagick")'
# - julia -e 'Pkg.clone("https://github.com/tbreloff/VisualRegressionTests.jl.git");'
- julia -e 'Pkg.clone("https://github.com/tbreloff/ExamplePlots.jl.git");' - julia -e 'Pkg.clone("https://github.com/tbreloff/ExamplePlots.jl.git");'
- julia -e 'Pkg.clone("https://github.com/JunoLab/Blink.jl.git"); Pkg.build("Blink"); import Blink; Blink.AtomShell.install()' - julia -e 'Pkg.clone("https://github.com/JunoLab/Blink.jl.git"); Pkg.build("Blink"); import Blink; Blink.AtomShell.install()'
- julia -e 'Pkg.clone("https://github.com/spencerlyon2/PlotlyJS.jl.git")' - julia -e 'Pkg.clone("https://github.com/spencerlyon2/PlotlyJS.jl.git")'

View File

@ -200,10 +200,10 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
E = zeros(length(p[:x]),2) E = zeros(length(p[:x]),2)
E[:,1] = p[:x] E[:,1] = p[:x]
E[:,2] = p[:y] E[:,2] = p[:y]
if isa(p[:nbins], Tuple) if isa(p[:bins], Tuple)
xbins, ybins = p[:nbins] xbins, ybins = p[:bins]
else else
xbins = ybins = p[:nbins] xbins = ybins = p[:bins]
end end
cmap = true cmap = true
x, y, H = Base.hist2d(E, xbins, ybins) x, y, H = Base.hist2d(E, xbins, ybins)
@ -473,10 +473,10 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
E = zeros(length(p[:x]),2) E = zeros(length(p[:x]),2)
E[:,1] = p[:x] E[:,1] = p[:x]
E[:,2] = p[:y] E[:,2] = p[:y]
if isa(p[:nbins], Tuple) if isa(p[:bins], Tuple)
xbins, ybins = p[:nbins] xbins, ybins = p[:bins]
else else
xbins = ybins = p[:nbins] xbins = ybins = p[:bins]
end end
x, y, H = Base.hist2d(E, xbins, ybins) x, y, H = Base.hist2d(E, xbins, ybins)
counts = round(Int32, 1000 + 255 * H / maximum(H)) counts = round(Int32, 1000 + 255 * H / maximum(H))

View File

@ -130,11 +130,12 @@ supportedArgs(::GRBackend) = [
:group, :group,
:label, :label,
:linetype, :linetype,
:seriescolor, :seriesalpha,
:linecolor, :linestyle, :linewidth, :linealpha, :linecolor, :linestyle, :linewidth, :linealpha,
:markershape, :markercolor, :markersize, :markeralpha, :markershape, :markercolor, :markersize, :markeralpha,
:markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :markerstrokewidth, :markerstrokecolor, :markerstrokealpha,
:fillrange, :fillcolor, :fillalpha, :fillrange, :fillcolor, :fillalpha,
:nbins, :bins,
:n, :nc, :nr, :layout, :n, :nc, :nr, :layout,
:smooth, :smooth,
:title, :windowtitle, :show, :size, :title, :windowtitle, :show, :size,
@ -145,7 +146,7 @@ supportedArgs(::GRBackend) = [
:z, :z,
:tickfont, :guidefont, :legendfont, :tickfont, :guidefont, :legendfont,
:grid, :legend, :colorbar, :grid, :legend, :colorbar,
:zcolor, :levels, :marker_z, :levels,
:xerror, :yerror, :xerror, :yerror,
:ribbon, :quiver, :ribbon, :quiver,
:orientation, :orientation,

View File

@ -30,6 +30,14 @@ function convertToAnyVector{T<:Number}(v::AMat{T}, d::KW)
end, nothing end, nothing
end end
# other matrix... vector of columns
function convertToAnyVector(m::AMat, d::KW)
Any[begin
v = vec(m[:,i])
length(v) == 1 ? v[1] : v
end for i=1:size(m,2)], nothing
end
# function # function
convertToAnyVector(f::Function, d::KW) = Any[f], nothing convertToAnyVector(f::Function, d::KW) = Any[f], nothing
@ -101,6 +109,13 @@ function build_series_args(plt::AbstractPlot, kw::KW) #, idxfilter)
ys, ymeta = convertToAnyVector(y, kw) ys, ymeta = convertToAnyVector(y, kw)
zs, zmeta = convertToAnyVector(z, kw) zs, zmeta = convertToAnyVector(z, kw)
fr = pop!(kw, :fillrange, nothing)
fillranges, _ = if typeof(fr) <: Number
([fr],nothing)
else
convertToAnyVector(fr, kw)
end
mx = length(xs) mx = length(xs)
my = length(ys) my = length(ys)
mz = length(zs) mz = length(zs)
@ -147,6 +162,9 @@ function build_series_args(plt::AbstractPlot, kw::KW) #, idxfilter)
if isa(d[:marker_z], Function) if isa(d[:marker_z], Function)
d[:marker_z] = map(d[:marker_z], d[:x]) d[:marker_z] = map(d[:marker_z], d[:x])
end end
# @show fillranges
d[:fillrange] = fillranges[mod1(i,length(fillranges))]
if isa(d[:fillrange], Function) if isa(d[:fillrange], Function)
d[:fillrange] = map(d[:fillrange], d[:x]) d[:fillrange] = map(d[:fillrange], d[:x])
end end

View File

@ -13,3 +13,4 @@ PyPlot
GR GR
DataFrames DataFrames
RDatasets RDatasets
VisualRegressionTests

View File

@ -23,14 +23,14 @@ facts("PyPlot") do
@fact pyplot() --> Plots.PyPlotBackend() @fact pyplot() --> Plots.PyPlotBackend()
@fact backend() --> Plots.PyPlotBackend() @fact backend() --> Plots.PyPlotBackend()
image_comparison_facts(:pyplot, skip=[19,23], eps=img_eps) image_comparison_facts(:pyplot, skip=[19], eps=img_eps)
end end
facts("GR") do facts("GR") do
@fact gr() --> Plots.GRBackend() @fact gr() --> Plots.GRBackend()
@fact backend() --> Plots.GRBackend() @fact backend() --> Plots.GRBackend()
@linux_only image_comparison_facts(:gr, skip=[13,27], eps=img_eps) @linux_only image_comparison_facts(:gr, skip=[24], eps=img_eps)
end end
facts("Plotly") do facts("Plotly") do