From d67aec6fecf830b975d9c9d4048b2f363d0cc1e9 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Thu, 28 Apr 2016 12:51:08 -0400 Subject: [PATCH] gr fixes and tests; fillrange convertToAnyVector --- .travis.yml | 7 ++++--- src/backends/gr.jl | 12 ++++++------ src/backends/supported.jl | 5 +++-- src/series_args.jl | 18 ++++++++++++++++++ test/REQUIRE | 1 + test/runtests.jl | 4 ++-- 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac556004..dee8962b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,9 +41,10 @@ script: - 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("Images"); Pkg.build("Images")' - # - 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("https://github.com/tbreloff/VisualRegressionTests.jl.git");' + - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")' + - julia -e 'Pkg.clone("GR"); Pkg.build("GR")' + # - 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/JunoLab/Blink.jl.git"); Pkg.build("Blink"); import Blink; Blink.AtomShell.install()' - julia -e 'Pkg.clone("https://github.com/spencerlyon2/PlotlyJS.jl.git")' diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 2ffedf40..cfff4c7e 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -200,10 +200,10 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, E = zeros(length(p[:x]),2) E[:,1] = p[:x] E[:,2] = p[:y] - if isa(p[:nbins], Tuple) - xbins, ybins = p[:nbins] + if isa(p[:bins], Tuple) + xbins, ybins = p[:bins] else - xbins = ybins = p[:nbins] + xbins = ybins = p[:bins] end cmap = true 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[:,1] = p[:x] E[:,2] = p[:y] - if isa(p[:nbins], Tuple) - xbins, ybins = p[:nbins] + if isa(p[:bins], Tuple) + xbins, ybins = p[:bins] else - xbins = ybins = p[:nbins] + xbins = ybins = p[:bins] end x, y, H = Base.hist2d(E, xbins, ybins) counts = round(Int32, 1000 + 255 * H / maximum(H)) diff --git a/src/backends/supported.jl b/src/backends/supported.jl index 0c642a88..a603f0f3 100644 --- a/src/backends/supported.jl +++ b/src/backends/supported.jl @@ -130,11 +130,12 @@ supportedArgs(::GRBackend) = [ :group, :label, :linetype, + :seriescolor, :seriesalpha, :linecolor, :linestyle, :linewidth, :linealpha, :markershape, :markercolor, :markersize, :markeralpha, :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, :fillrange, :fillcolor, :fillalpha, - :nbins, + :bins, :n, :nc, :nr, :layout, :smooth, :title, :windowtitle, :show, :size, @@ -145,7 +146,7 @@ supportedArgs(::GRBackend) = [ :z, :tickfont, :guidefont, :legendfont, :grid, :legend, :colorbar, - :zcolor, :levels, + :marker_z, :levels, :xerror, :yerror, :ribbon, :quiver, :orientation, diff --git a/src/series_args.jl b/src/series_args.jl index 36156e79..7bab4337 100644 --- a/src/series_args.jl +++ b/src/series_args.jl @@ -30,6 +30,14 @@ function convertToAnyVector{T<:Number}(v::AMat{T}, d::KW) end, nothing 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 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) 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) my = length(ys) mz = length(zs) @@ -147,6 +162,9 @@ function build_series_args(plt::AbstractPlot, kw::KW) #, idxfilter) if isa(d[:marker_z], Function) d[:marker_z] = map(d[:marker_z], d[:x]) end + + # @show fillranges + d[:fillrange] = fillranges[mod1(i,length(fillranges))] if isa(d[:fillrange], Function) d[:fillrange] = map(d[:fillrange], d[:x]) end diff --git a/test/REQUIRE b/test/REQUIRE index ba55ab04..bbed05ec 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -13,3 +13,4 @@ PyPlot GR DataFrames RDatasets +VisualRegressionTests diff --git a/test/runtests.jl b/test/runtests.jl index 34981015..86f48424 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,14 +23,14 @@ facts("PyPlot") do @fact pyplot() --> 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 facts("GR") do @fact gr() --> 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 facts("Plotly") do