From ac73798b9d4801f08ef93e4f7fc9e92ad69db865 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 16 Aug 2018 11:59:56 +0200 Subject: [PATCH 01/21] actually use PlotsDisplay() instead of overloading display for REPLDisplay --- src/Plots.jl | 1 + src/output.jl | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index 854b13bf..ac99a187 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -304,6 +304,7 @@ const CURRENT_BACKEND = CurrentBackend(:none) k == :theme || default(k, v) end end + pushdisplay(PlotsDisplay()) end # --------------------------------------------------------- diff --git a/src/output.jl b/src/output.jl index 7c762d6b..dbee501b 100644 --- a/src/output.jl +++ b/src/output.jl @@ -145,11 +145,6 @@ function Base.display(::PlotsDisplay, plt::Plot) _display(plt) end -# override the REPL display to open a gui window -using REPL -Base.display(::REPL.REPLDisplay, ::MIME"text/plain", plt::Plot) = gui(plt) - - _do_plot_show(plt, showval::Bool) = showval && gui(plt) function _do_plot_show(plt, showval::Symbol) showval == :gui && gui(plt) From 6593e3cfe6d1f99b2404524c7d86dce260671d2a Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 16 Aug 2018 12:23:23 +0200 Subject: [PATCH 02/21] actually use __init__ --- src/Plots.jl | 15 --------------- src/init.jl | 10 ++++++++++ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index ac99a187..d63282f9 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -294,19 +294,4 @@ end const CURRENT_BACKEND = CurrentBackend(:none) -# for compatibility with Requires.jl: -@init begin - if isdefined(Main, :PLOTS_DEFAULTS) - if haskey(Main.PLOTS_DEFAULTS, :theme) - theme(Main.PLOTS_DEFAULTS[:theme]) - end - for (k,v) in Main.PLOTS_DEFAULTS - k == :theme || default(k, v) - end - end - pushdisplay(PlotsDisplay()) -end - -# --------------------------------------------------------- - end # module diff --git a/src/init.jl b/src/init.jl index 53f5898b..51865535 100644 --- a/src/init.jl +++ b/src/init.jl @@ -1,4 +1,14 @@ function __init__() + if isdefined(Main, :PLOTS_DEFAULTS) + if haskey(Main.PLOTS_DEFAULTS, :theme) + theme(Main.PLOTS_DEFAULTS[:theme]) + end + for (k,v) in Main.PLOTS_DEFAULTS + k == :theme || default(k, v) + end + end + pushdisplay(PlotsDisplay()) + include(joinpath(@__DIR__, "backends", "plotly.jl")) include(joinpath(@__DIR__, "backends", "gr.jl")) include(joinpath(@__DIR__, "backends", "web.jl")) From 00be8a223790cc54cfb8f3cedadc911e75da857b Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 16 Aug 2018 12:34:33 +0200 Subject: [PATCH 03/21] make sure display order is correct if Plots is loaded before the REPL --- src/init.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/init.jl b/src/init.jl index 51865535..9cf52741 100644 --- a/src/init.jl +++ b/src/init.jl @@ -9,6 +9,13 @@ function __init__() end pushdisplay(PlotsDisplay()) + atreplinit(i -> begin + if PlotDisplay() in Base.Multimedia.displays + popdisplay(PlotsDisplay()) + end + pushdisplay(PlotsDisplay()) + end) + include(joinpath(@__DIR__, "backends", "plotly.jl")) include(joinpath(@__DIR__, "backends", "gr.jl")) include(joinpath(@__DIR__, "backends", "web.jl")) From def5be630a217ea9ed60faf984c051cd12f37b6e Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 14:18:45 -0700 Subject: [PATCH 04/21] Use Pkg3 API in travis_commands.jl --- test/travis_commands.jl | 49 ++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/test/travis_commands.jl b/test/travis_commands.jl index b4e6ff7e..cd6363ec 100644 --- a/test/travis_commands.jl +++ b/test/travis_commands.jl @@ -1,34 +1,29 @@ using Pkg -Pkg.add("ImageMagick") -Pkg.build("ImageMagick") - -# Pkg.clone("GR") -# Pkg.build("GR") - -Pkg.checkout("https://github.com/JuliaPlots/PlotReferenceImages.jl.git") - -# Pkg.clone("https://github.com/JuliaStats/KernelDensity.jl.git") - -# Pkg.add("StatPlots") -Pkg.checkout("PlotUtils") -Pkg.checkout("RecipesBase") - -# Pkg.clone("Blink") -# Pkg.build("Blink") -# import Blink -# Blink.AtomShell.install() -# Pkg.add("Rsvg") -# Pkg.add("PlotlyJS") - -# Pkg.checkout("RecipesBase") -# Pkg.clone("VisualRegressionTests") - # need this to use Conda # ENV["PYTHON"] = "" -# Pkg.add("PyPlot") + +Pkg.add([ + PackageSpec("ImageMagick"), + # PackageSpec("GR"), + PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"), + PackageSpec("StatPlots"), + # PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"), + PackageSpec(name="PlotUtils", rev="master"), + PackageSpec(name="RecipesBase", rev="master"), + # PackageSpec(name="Blink", rev="master"), + # PackageSpec(name="Rsvg", rev="master"), + # PackageSpec(name="PlotlyJS", rev="master"), + # PackageSpec(name="VisualRegressionTests", rev="master"), + # PackageSpec("PyPlot"), + # PackageSpec("InspectDR"), +]) + +Pkg.build("ImageMagick") +# Pkg.build("GR") +# Pkg.build("Blink") +# import Blink +# Blink.AtomShell.install() # Pkg.build("PyPlot") -# Pkg.add("InspectDR") - Pkg.test("Plots"; coverage=false) From 7fcd008f2ff319a21b65ef14722871a5ae804427 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 14:32:05 -0700 Subject: [PATCH 05/21] Fix appveyor.yml --- appveyor.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a626cae5..e43c45b6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,8 +31,12 @@ install: build_script: # Need to convert from shallow to complete for Pkg.clone to work - IF EXIST .git\shallow (git fetch --unshallow) - - C:\projects\julia\bin\julia -e "versioninfo(); Pkg.clone(pwd(), \"Plots\"); Pkg.build(\"Plots\")" + - C:\projects\julia\bin\julia -e " + using InteractiveUtils, Pkg; + versioninfo(); + Pkg.clone(pwd(), \"Plots\"); + Pkg.build(\"Plots\")" test_script: # - C:\projects\julia\bin\julia -e "Pkg.test(\"Plots\")" - - C:\projects\julia\bin\julia -e "include(Pkg.dir(\"Plots\", \"test\", \"travis_commands.jl\"))" + - C:\projects\julia\bin\julia test\travis_commands.jl From 4a51e4e7fb5fb5519dfc36ea55e1aa7ec7423c5f Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 15:39:20 -0700 Subject: [PATCH 06/21] Import Random --- test/imgcomp.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index abc08b13..ea15284c 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -15,6 +15,7 @@ using VisualRegressionTests using Plots # using StatPlots +using Random using Test default(size=(500,300)) From 374580a3d6735d97cd5e6ba85c039b28048ff1f4 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 15:50:22 -0700 Subject: [PATCH 07/21] Import Pkg --- test/imgcomp.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index ea15284c..b580b1a7 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -15,6 +15,7 @@ using VisualRegressionTests using Plots # using StatPlots +using Pkg using Random using Test From 80da14c1fbefcfd92329c32a445941fe84567c27 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 21:01:56 -0700 Subject: [PATCH 08/21] Use pathof(PlotReferenceImages) instead of Pkg.dir --- test/imgcomp.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index b580b1a7..0bec9b52 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -15,7 +15,7 @@ using VisualRegressionTests using Plots # using StatPlots -using Pkg +using PlotReferenceImages using Random using Test @@ -40,7 +40,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is # reference image directory setup # refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg)) - refdir = Pkg.dir("PlotReferenceImages", "Plots", string(pkg)) + refdir = joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots", string(pkg)) fn = "ref$idx.png" # firgure out version info From e483ce85dcb3964e81ebe8300c75cc1a6a8a8b51 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 21:02:48 -0700 Subject: [PATCH 09/21] Install unregistered packages in test/runtests.jl --- .travis.yml | 8 ++++---- appveyor.yml | 3 +-- test/{travis_commands.jl => add_packages.jl} | 5 ----- test/runtests.jl | 1 + 4 files changed, 6 insertions(+), 11 deletions(-) rename test/{travis_commands.jl => add_packages.jl} (85%) diff --git a/.travis.yml b/.travis.yml index fb9a97a2..31817d0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,10 +43,10 @@ before_install: notifications: email: true # uncomment the following lines to override the default test script -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); Pkg.build("Plots")' - - julia test/travis_commands.jl +# script: + # - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi + # - julia -e 'import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); Pkg.build("Plots")' + # - julia test/travis_commands.jl # - 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")' diff --git a/appveyor.yml b/appveyor.yml index e43c45b6..15796f23 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -38,5 +38,4 @@ build_script: Pkg.build(\"Plots\")" test_script: - # - C:\projects\julia\bin\julia -e "Pkg.test(\"Plots\")" - - C:\projects\julia\bin\julia test\travis_commands.jl + - C:\projects\julia\bin\julia -e "using Pkg; Pkg.test(\"Plots\")" diff --git a/test/travis_commands.jl b/test/add_packages.jl similarity index 85% rename from test/travis_commands.jl rename to test/add_packages.jl index cd6363ec..655ec4d6 100644 --- a/test/travis_commands.jl +++ b/test/add_packages.jl @@ -4,10 +4,7 @@ using Pkg # ENV["PYTHON"] = "" Pkg.add([ - PackageSpec("ImageMagick"), - # PackageSpec("GR"), PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"), - PackageSpec("StatPlots"), # PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"), PackageSpec(name="PlotUtils", rev="master"), PackageSpec(name="RecipesBase", rev="master"), @@ -25,5 +22,3 @@ Pkg.build("ImageMagick") # import Blink # Blink.AtomShell.install() # Pkg.build("PyPlot") - -Pkg.test("Plots"; coverage=false) diff --git a/test/runtests.jl b/test/runtests.jl index fd9f00bf..61d0e049 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,6 @@ module PlotsTests +include("add_packages.jl") include("imgcomp.jl") # don't actually show the plots From 531dd432841b5e864a8e49f49de4619199c572b0 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 21:37:27 -0700 Subject: [PATCH 10/21] Add FileIO to test/REQUIRE --- test/REQUIRE | 1 + 1 file changed, 1 insertion(+) diff --git a/test/REQUIRE b/test/REQUIRE index 6cd6a973..a11706d9 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -2,6 +2,7 @@ StatPlots Images ImageMagick @osx QuartzImageIO +FileIO GR 0.31.0 RDatasets VisualRegressionTests From eefea1506912aebb8f961faff0b9bca30dca4ea4 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 23 Aug 2018 21:41:26 -0700 Subject: [PATCH 11/21] Don't use Base.mean --- src/Plots.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plots.jl b/src/Plots.jl index 2b96c5cb..502996ba 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -116,7 +116,7 @@ ignorenan_minimum(x) = Base.minimum(x) ignorenan_maximum(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.maximum(x) ignorenan_maximum(x) = Base.maximum(x) ignorenan_mean(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.mean(x) -ignorenan_mean(x) = Base.mean(x) +ignorenan_mean(x) = mean(x) ignorenan_extrema(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.extrema(x) ignorenan_extrema(x) = Base.extrema(x) From ebf32390ef56f6a71cd54ddf4324031e67e35dc2 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 Aug 2018 17:16:05 -0700 Subject: [PATCH 12/21] Import Gtk in interactive session --- test/imgcomp.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 0bec9b52..8294c1f7 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -2,6 +2,10 @@ using VisualRegressionTests # using ExamplePlots +if isinteractive() + @eval Main import Gtk +end + # import DataFrames, RDatasets # don't let pyplot use a gui... it'll crash From 6d0d8ea90aefb3044c3d9778cfb6e7ff2c5ef11a Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sat, 25 Aug 2018 07:14:33 -0700 Subject: [PATCH 13/21] Use qualified name Statistics.mean --- src/Plots.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plots.jl b/src/Plots.jl index 502996ba..e02cc169 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -116,7 +116,7 @@ ignorenan_minimum(x) = Base.minimum(x) ignorenan_maximum(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.maximum(x) ignorenan_maximum(x) = Base.maximum(x) ignorenan_mean(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.mean(x) -ignorenan_mean(x) = mean(x) +ignorenan_mean(x) = Statistics.mean(x) ignorenan_extrema(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.extrema(x) ignorenan_extrema(x) = Base.extrema(x) From e0f9313b8b22df896022274f3adf3516dae6eb89 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sat, 25 Aug 2018 07:15:24 -0700 Subject: [PATCH 14/21] Use import PlotReferenceImages --- test/imgcomp.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 8294c1f7..92841b92 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -19,7 +19,7 @@ end using Plots # using StatPlots -using PlotReferenceImages +import PlotReferenceImages using Random using Test From 937acbc21820c4be630e5ae6594e71d490190df6 Mon Sep 17 00:00:00 2001 From: Pietro Vertechi Date: Sat, 25 Aug 2018 19:04:42 +0100 Subject: [PATCH 15/21] sort x axis in group_as_matrix --- src/series.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/series.jl b/src/series.jl index 702c210a..52e8c1ec 100644 --- a/src/series.jl +++ b/src/series.jl @@ -636,7 +636,7 @@ group_as_matrix(t) = false x = g.args[1] last_args = g.args[2:end] end - x_u = unique(x) + x_u = unique(sort(x)) x_ind = Dict(zip(x_u, 1:length(x_u))) for (key,val) in plotattributes if splittable_kw(key, val, lengthGroup) From 00821c1ae310e5aaa678e0fb8f67702cf3a719b6 Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Sat, 25 Aug 2018 14:49:52 -0400 Subject: [PATCH 16/21] Add :match_dimensions to address #1694 see also #273 and #196, for f(x,y) vs f(y,x), and transpose=true --- src/backends/gr.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 2215c456..a3ba0fba 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -18,6 +18,7 @@ const _gr_attr = merge_with_base_supported([ :layout, :title, :window_title, :guide, :lims, :ticks, :scale, :flip, + :match_dimensions, :titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign, :titlefontrotation, :titlefontcolor, :legendfontfamily, :legendfontsize, :legendfonthalign, :legendfontvalign, From b2f2ffcfed428d4f22b3acfe469eb389265c9c99 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 26 Aug 2018 21:11:23 +0200 Subject: [PATCH 17/21] fix tests --- src/examples.jl | 21 ++++++++++++--------- test/add_packages.jl | 15 +++++++++++++-- test/imgcomp.jl | 8 ++++---- test/runtests.jl | 18 +++++++++--------- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/examples.jl b/src/examples.jl index 71c41a8c..e9155d0e 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -52,7 +52,7 @@ the `z` argument to turn on series gradients. [:(begin y = rand(100) plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=0, α=0.6) -scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,stroke(1,:green)), ms=10*abs.(y.-0.5).+4, +scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,Plots.stroke(1,:green)), ms=10*abs.(y.-0.5).+4, lab="grad") end)] ), @@ -66,6 +66,7 @@ the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!` `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!` """, [:(begin +using Statistics y = rand(20,3) plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), leg=false) @@ -85,8 +86,8 @@ yaxis!("YLABEL", :log10) PlotExample("Images", "Plot an image. y-axis is set to flipped", [:(begin - import FileIO - img = FileIO.load(Pkg.dir("PlotReferenceImages","Plots","pyplot","0.7.0","ref1.png")) + import FileIO, PlotReferenceImages + img = FileIO.load(joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots","pyplot","0.7.0","ref1.png")) plot(img) end)] ), @@ -102,7 +103,7 @@ series. """, [:(begin ys = Vector[rand(10), rand(20)] - plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,stroke(3,:gray))) + plot(ys, color=[:black :orange], line=(:dot,4), marker=([:hex :d],12,0.8,Plots.stroke(3,:gray))) end)] ), @@ -202,7 +203,8 @@ plot(Plots.fakedata(100,10), layout=4, palette=[:grays :blues :heat :lightrainbo PlotExample("", "", [:(begin - Random.srand(111) + using Random + Random.seed!(111) plot!(Plots.fakedata(100,10)) end)] ), @@ -295,7 +297,7 @@ PlotExample("3D", x = ts .* map(cos,ts) y = 0.1ts .* map(sin,ts) z = 1:n - plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,stroke(0)), leg=false, cbar=true, w=5) + plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,Plots.stroke(0)), leg=false, cbar=true, w=5) plot!(zeros(n),zeros(n),1:n, w=10) end)] ), @@ -382,8 +384,9 @@ various different nonzero values, a colorbar is added. The colorbar can be disab `legend = nothing`. """, [:(begin - a = spdiagm((ones(50), ones(49), ones(49), ones(40), ones(40)),(0, 1, -1, 10, -10)) - b = spdiagm((1:50, 1:49, 1:49, 1:40, 1:40),(0, 1, -1, 10, -10)) + using SparseArrays + a = spdiagm(0 => ones(50), 1 => ones(49), -1 => ones(49), 10 => ones(40), -10 => ones(40)) + b = spdiagm(0 => 1:50, 1 => 1:49, -1 => 1:49, 10 => 1:40, -10 => 1:40) plot(spy(a), spy(b), title = ["Unique nonzeros" "Different nonzeros"]) end)] ), @@ -411,7 +414,7 @@ attribute. The default framestyle is `:axes`. scatter(fill(randn(10), 6), fill(randn(10), 6), framestyle = [:box :semi :origin :zerolines :grid :none], title = [":box" ":semi" ":origin" ":zerolines" ":grid" ":none"], - color = RowVector(1:6), layout = 6, label = "", markerstrokewidth = 0, + color = permutedims(1:6), layout = 6, label = "", markerstrokewidth = 0, ticks = -2:2) end)] ), diff --git a/test/add_packages.jl b/test/add_packages.jl index 655ec4d6..260707d3 100644 --- a/test/add_packages.jl +++ b/test/add_packages.jl @@ -3,7 +3,7 @@ using Pkg # need this to use Conda # ENV["PYTHON"] = "" -Pkg.add([ +to_add = [ PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"), # PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"), PackageSpec(name="PlotUtils", rev="master"), @@ -14,7 +14,18 @@ Pkg.add([ # PackageSpec(name="VisualRegressionTests", rev="master"), # PackageSpec("PyPlot"), # PackageSpec("InspectDR"), -]) +] + +if isinteractive() + append!(to_add, [ + PackageSpec(name="FileIO"), + PackageSpec(name="ImageMagick"), + PackageSpec(name="UnicodePlots"), + PackageSpec(name="VisualRegressionTests"), + ]) +end + +Pkg.add(to_add) Pkg.build("ImageMagick") # Pkg.build("GR") diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 92841b92..1145f272 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -32,7 +32,7 @@ default(size=(500,300)) const _current_plots_version = v"0.17.4" -function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], eps = 1e-2) +function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], tol = 1e-2) Plots._debugMode.on = debug example = Plots._examples[idx] @info("Testing plot: $pkg:$idx:$(example.header)") @@ -89,7 +89,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is # the test vtest = VisualTest(func, reffn, idx) - test_images(vtest, popup=popup, sigma=sigma, eps=eps, newfn = newfn) + test_images(vtest, popup=popup, sigma=sigma, tol=tol, newfn = newfn) end function image_comparison_facts(pkg::Symbol; @@ -97,11 +97,11 @@ function image_comparison_facts(pkg::Symbol; only = nothing, # limit to these examples (int index) debug = false, # print debug information? sigma = [1,1], # number of pixels to "blur" - eps = 1e-2) # acceptable error (percent) + tol = 1e-2) # acceptable error (percent) for i in 1:length(Plots._examples) i in skip && continue if only == nothing || i in only - @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success == true + @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, tol=tol) |> success == true end end end diff --git a/test/runtests.jl b/test/runtests.jl index 61d0e049..543b8ea3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,7 +6,7 @@ include("imgcomp.jl") # don't actually show the plots Random.seed!(1234) default(show=false, reuse=true) -img_eps = isinteractive() ? 1e-2 : 10e-2 +img_tol = isinteractive() ? 1e-2 : 10e-2 @testset "GR" begin ENV["PLOTS_TEST"] = "true" @@ -14,7 +14,7 @@ img_eps = isinteractive() ? 1e-2 : 10e-2 @test gr() == Plots.GRBackend() @test backend() == Plots.GRBackend() - image_comparison_facts(:gr, eps=img_eps, skip = [25, 30]) + image_comparison_facts(:gr, tol=img_tol, skip = [25, 30]) end @@ -22,7 +22,7 @@ end # @test pyplot() == Plots.PyPlotBackend() # @test backend() == Plots.PyPlotBackend() # -# image_comparison_facts(:pyplot, eps=img_eps) +# image_comparison_facts(:pyplot, tol=img_tol) #end @testset "UnicodePlots" begin @@ -47,7 +47,7 @@ end # 27, # (polar plots) takes very long / not working # 31, # animation (skipped for speed) # ], -# eps=img_eps) +# tol=img_tol) # end # end @@ -71,7 +71,7 @@ end # 28, # heatmap not defined # 31, # animation # ], -# eps=img_eps) +# tol=img_tol) # end @@ -80,7 +80,7 @@ end # @test backend() == Plots.PlotlyBackend() # # # # until png generation is reliable on OSX, just test on linux -# # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) +# # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], tol=img_tol) # end @@ -89,7 +89,7 @@ end # @test backend() == Plots.ImmerseBackend() # # # as long as we can plot anything without error, it should be the same as Gadfly -# image_comparison_facts(:immerse, only=[1], eps=img_eps) +# image_comparison_facts(:immerse, only=[1], tol=img_tol) # end @@ -98,7 +98,7 @@ end # @test backend() == Plots.PlotlyJSBackend() # # # as long as we can plot anything without error, it should be the same as Plotly -# image_comparison_facts(:plotlyjs, only=[1], eps=img_eps) +# image_comparison_facts(:plotlyjs, only=[1], tol=img_tol) # end @@ -111,7 +111,7 @@ end # @test plot(sort(rand(10)), rand(Int, 10, 3)) == not(nothing) # @test plot!(rand(10,3), rand(10,3)) == not(nothing) # -# image_comparison_facts(:gadfly, skip=[4,6,23,24,27], eps=img_eps) +# image_comparison_facts(:gadfly, skip=[4,6,23,24,27], tol=img_tol) # end From e991e2bf377ab36c980415a6caf1f800b4607e6d Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 24 Aug 2018 16:40:49 +0200 Subject: [PATCH 18/21] implement additional get_***color methods --- src/utils.jl | 78 ++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index f76785fe..e58bc1c6 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -617,20 +617,40 @@ function hascolorbar(sp::Subplot) hascbar end -function get_linecolor(series, i::Int = 1) - lc = series[:linecolor] - lz = series[:line_z] - if lz == nothing - isa(lc, ColorGradient) ? lc : plot_color(_cycle(lc, i)) - else - cmin, cmax = get_clims(series[:subplot]) - grad = isa(lc, ColorGradient) ? lc : cgrad() - grad[clamp((_cycle(lz, i) - cmin) / (cmax - cmin), 0, 1)] - end -end +for comp in (:line, :fill, :marker) -function get_linealpha(series, i::Int = 1) - _cycle(series[:linealpha], i) + compcolor = Symbol(comp, :color) + get_compcolor = Symbol(:get_, compcolor) + comp_z = Symbol(comp, :_z) + + compalpha = Symbol(comp, :alpha) + get_compalpha = Symbol(:get_, compalpha) + + @eval begin + + function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1) + c = series[$Symbol(compcolor)] + z = series[$Symbol(comp_z)] + if z == nothing + isa(c, ColorGradient) ? c : plot_color(_cycle(c, i)) + else + grad = isa(c, ColorGradient) ? c : cgrad() + grad[clamp((_cycle(z, i) - cmin) / (cmax - cmin), 0, 1)] + end + end + + $get_compcolor(series, clims, i::Int = i) = $get_compcolor(series, clims[1], clims[2], i) + + function $get_compcolor(series, i::Int = 1) + if series[$Symbol(comp_z)] == nothing + $get_compcolor(series, 0, 1, i) + else + $get_compcolor(series, get_clims(series[:subplot]), i) + end + end + + $get_compalpha(series, i::Int = 1) = _cycle(series[$compalpha], i) + end end function get_linewidth(series, i::Int = 1) @@ -641,38 +661,6 @@ function get_linestyle(series, i::Int = 1) _cycle(series[:linestyle], i) end -function get_fillcolor(series, i::Int = 1) - fc = series[:fillcolor] - fz = series[:fill_z] - if fz == nothing - isa(fc, ColorGradient) ? fc : plot_color(_cycle(fc, i)) - else - cmin, cmax = get_clims(series[:subplot]) - grad = isa(fc, ColorGradient) ? fc : cgrad() - grad[clamp((_cycle(fz, i) - cmin) / (cmax - cmin), 0, 1)] - end -end - -function get_fillalpha(series, i::Int = 1) - _cycle(series[:fillalpha], i) -end - -function get_markercolor(series, i::Int = 1) - mc = series[:markercolor] - mz = series[:marker_z] - if mz == nothing - isa(mc, ColorGradient) ? mc : plot_color(_cycle(mc, i)) - else - cmin, cmax = get_clims(series[:subplot]) - grad = isa(mc, ColorGradient) ? mc : cgrad() - grad[clamp((_cycle(mz, i) - cmin) / (cmax - cmin), 0, 1)] - end -end - -function get_markeralpha(series, i::Int = 1) - _cycle(series[:markeralpha], i) -end - function get_markerstrokecolor(series, i::Int = 1) msc = series[:markerstrokecolor] isa(msc, ColorGradient) ? msc : _cycle(msc, i) From 84601bacdbb3230964bde091384a28beab9bb4e7 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 24 Aug 2018 17:20:19 +0200 Subject: [PATCH 19/21] gr implementation --- src/backends/gr.jl | 33 +++++++++++++++------------------ src/utils.jl | 16 ++++++++-------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 2215c456..480bb89f 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -338,7 +338,11 @@ end # draw the markers, one at a time -function gr_draw_markers(series::Series, x, y, msize, mz) +function gr_draw_markers(series::Series, x, y, clims, msize = series[:markersize]) + + isempty(x) && return + GR.setfillintstyle(GR.INTSTYLE_SOLID) + shapes = series[:markershape] if shapes != :none for i=1:length(x) @@ -355,7 +359,7 @@ function gr_draw_markers(series::Series, x, y, msize, mz) # draw the shape - don't draw filled area if marker shape is 1D if !(shape in (:hline, :vline, :+, :x)) - cfunc(get_markercolor(series, i)) + cfunc(get_markercolor(series, clims, i)) gr_set_transparency(get_markeralpha(series, i)) gr_draw_marker(x[i], y[i], msi, shape) end @@ -363,13 +367,6 @@ function gr_draw_markers(series::Series, x, y, msize, mz) end end -function gr_draw_markers(series::Series, x, y, clims) - isempty(x) && return - mz = normalize_zvals(series[:marker_z], clims) - GR.setfillintstyle(GR.INTSTYLE_SOLID) - gr_draw_markers(series, x, y, series[:markersize], mz) -end - # --------------------------------------------------------- function gr_set_line(lw, style, c) #, a) @@ -1038,7 +1035,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) GR.setfillintstyle(GR.INTSTYLE_SOLID) fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng)) for (i, rng) in enumerate(segments) - gr_set_fillcolor(get_fillcolor(series, i)) + gr_set_fillcolor(get_fillcolor(series, clims, i)) fx = _cycle(x, vcat(rng, reverse(rng))) fy = vcat(_cycle(fr_from,rng), _cycle(fr_to,reverse(rng))) gr_set_transparency(get_fillalpha(series, i)) @@ -1049,7 +1046,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) # draw the line(s) if st in (:path, :straightline) for (i, rng) in enumerate(segments) - gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, i)) #, series[:linealpha]) + gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, clims, i)) #, series[:linealpha]) gr_set_transparency(get_linealpha(series, i)) arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none gr_polyline(x[rng], y[rng]; arrowside = arrowside) @@ -1129,7 +1126,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) lz = series[:line_z] segments = iter_segments(series) for (i, rng) in enumerate(segments) - gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, i)) #, series[:linealpha]) + gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, clims, i)) #, series[:linealpha]) gr_set_transparency(get_linealpha(series, i)) GR.polyline3d(x[rng], y[rng], z[rng]) end @@ -1201,12 +1198,12 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) xseg, yseg = x[rng], y[rng] # draw the interior - gr_set_fill(get_fillcolor(series, i)) + gr_set_fill(get_fillcolor(series, clims, i)) gr_set_transparency(get_fillalpha(series, i)) GR.fillarea(xseg, yseg) # draw the shapes - gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, i)) + gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, clims, i)) gr_set_transparency(get_linealpha(series, i)) GR.polyline(xseg, yseg) end @@ -1298,10 +1295,10 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) for series in series_list(sp) should_add_to_legend(series) || continue st = series[:seriestype] - gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series)) #, series[:linealpha]) + gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series, clims)) #, series[:linealpha]) if (st == :shape || series[:fillrange] != nothing) && series[:ribbon] == nothing - gr_set_fill(get_fillcolor(series)) #, series[:fillalpha]) + gr_set_fill(get_fillcolor(series, clims)) #, series[:fillalpha]) l, r = xpos-0.07, xpos-0.01 b, t = ypos-0.4dy, ypos+0.4dy x = [l, r, r, l, l] @@ -1309,7 +1306,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) gr_set_transparency(get_fillalpha(series)) gr_polyline(x, y, GR.fillarea) gr_set_transparency(get_linealpha(series)) - gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series)) + gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series, clims)) st == :shape && gr_polyline(x, y) end @@ -1323,7 +1320,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) end if series[:markershape] != :none - gr_draw_markers(series, xpos - .035, ypos, 6, nothing) + gr_draw_markers(series, xpos - .035, ypos, clims, 6) end if typeof(series[:label]) <: Array diff --git a/src/utils.jl b/src/utils.jl index e58bc1c6..ff15e7a8 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -619,18 +619,18 @@ end for comp in (:line, :fill, :marker) - compcolor = Symbol(comp, :color) + compcolor = string(comp, :color) get_compcolor = Symbol(:get_, compcolor) - comp_z = Symbol(comp, :_z) + comp_z = string(comp, :_z) - compalpha = Symbol(comp, :alpha) + compalpha = string(comp, :alpha) get_compalpha = Symbol(:get_, compalpha) @eval begin function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1) - c = series[$Symbol(compcolor)] - z = series[$Symbol(comp_z)] + c = series[$Symbol($compcolor)] + z = series[$Symbol($comp_z)] if z == nothing isa(c, ColorGradient) ? c : plot_color(_cycle(c, i)) else @@ -639,17 +639,17 @@ for comp in (:line, :fill, :marker) end end - $get_compcolor(series, clims, i::Int = i) = $get_compcolor(series, clims[1], clims[2], i) + $get_compcolor(series, clims, i::Int = 1) = $get_compcolor(series, clims[1], clims[2], i) function $get_compcolor(series, i::Int = 1) - if series[$Symbol(comp_z)] == nothing + if series[$Symbol($comp_z)] == nothing $get_compcolor(series, 0, 1, i) else $get_compcolor(series, get_clims(series[:subplot]), i) end end - $get_compalpha(series, i::Int = 1) = _cycle(series[$compalpha], i) + $get_compalpha(series, i::Int = 1) = _cycle(series[$Symbol($compalpha)], i) end end From e1a83aab1df30c9b4cfb29ed29fbb9550ed22bc0 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 24 Aug 2018 18:13:47 +0200 Subject: [PATCH 20/21] implement plotly --- src/backends/plotly.jl | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 810a5e88..19788118 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -530,11 +530,14 @@ as_gradient(grad, α) = cgrad(alpha = α) # get a dictionary representing the series params (d is the Plots-dict, d_out is the Plotly-dict) function plotly_series(plt::Plot, series::Series) st = series[:seriestype] - if st == :shape - return plotly_series_shapes(plt, series) - end sp = series[:subplot] + clims = get_clims(sp) + + if st == :shape + return plotly_series_shapes(plt, series, clims) + end + d_out = KW() # these are the axes that the series should be mapped to @@ -564,14 +567,13 @@ function plotly_series(plt::Plot, series::Series) d_out[:colorbar] = KW(:title => sp[:colorbar_title]) - clims = sp[:clims] if is_2tuple(clims) d_out[:zmin], d_out[:zmax] = clims end # set the "type" if st in (:path, :scatter, :scattergl, :straightline, :path3d, :scatter3d) - return plotly_series_segments(series, d_out, x, y, z) + return plotly_series_segments(series, d_out, x, y, z, clims) elseif st == :heatmap x = heatmap_edges(x, sp[:xaxis][:scale]) @@ -643,7 +645,7 @@ function plotly_series(plt::Plot, series::Series) return [d_out] end -function plotly_series_shapes(plt::Plot, series::Series) +function plotly_series_shapes(plt::Plot, series::Series, clims) segments = iter_segments(series) d_outs = Vector{KW}(undef, length(segments)) @@ -673,11 +675,11 @@ function plotly_series_shapes(plt::Plot, series::Series) :x => vcat(x[rng], x[rng[1]]), :y => vcat(y[rng], y[rng[1]]), :fill => "tozeroy", - :fillcolor => rgba_string(plot_color(get_fillcolor(series, i), get_fillalpha(series, i))), + :fillcolor => rgba_string(plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i))), )) if series[:markerstrokewidth] > 0 d_out[:line] = KW( - :color => rgba_string(plot_color(get_linecolor(series, i), get_linealpha(series, i))), + :color => rgba_string(plot_color(get_linecolor(series, clims, i), get_linealpha(series, i))), :width => get_linewidth(series, i), :dash => string(get_linestyle(series, i)), ) @@ -697,7 +699,7 @@ function plotly_series_shapes(plt::Plot, series::Series) d_outs end -function plotly_series_segments(series::Series, d_base::KW, x, y, z) +function plotly_series_segments(series::Series, d_base::KW, x, y, z, clims) st = series[:seriestype] sp = series[:subplot] isscatter = st in (:scatter, :scatter3d, :scattergl) @@ -726,10 +728,10 @@ function plotly_series_segments(series::Series, d_base::KW, x, y, z) end if series[:fillrange] == true || series[:fillrange] == 0 || isa(series[:fillrange], Tuple) d_out[:fill] = "tozeroy" - d_out[:fillcolor] = rgba_string(plot_color(get_fillcolor(series, i), get_fillalpha(series, i))) + d_out[:fillcolor] = rgba_string(plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i))) elseif typeof(series[:fillrange]) <: Union{AbstractVector{<:Real}, Real} d_out[:fill] = "tonexty" - d_out[:fillcolor] = rgba_string(plot_color(get_fillcolor(series, i), get_fillalpha(series, i))) + d_out[:fillcolor] = rgba_string(plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i))) elseif !(series[:fillrange] in (false, nothing)) @warn("fillrange ignored... plotly only supports filling to zero and to a vector of values. fillrange: $(series[:fillrange])") end @@ -751,7 +753,7 @@ function plotly_series_segments(series::Series, d_base::KW, x, y, z) :symbol => get(_plotly_markers, _cycle(series[:markershape], i), string(_cycle(series[:markershape], i))), # :opacity => series[:markeralpha], :size => 2 * _cycle(series[:markersize], i), - :color => rgba_string(plot_color(get_markercolor(series, i), get_markeralpha(series, i))), + :color => rgba_string(plot_color(get_markercolor(series, clims, i), get_markeralpha(series, i))), :line => KW( :color => rgba_string(plot_color(get_markerstrokecolor(series, i), get_markerstrokealpha(series, i))), :width => _cycle(series[:markerstrokewidth], i), @@ -762,7 +764,7 @@ function plotly_series_segments(series::Series, d_base::KW, x, y, z) # add "line" if hasline d_out[:line] = KW( - :color => rgba_string(plot_color(get_linecolor(series, i), get_linealpha(series, i))), + :color => rgba_string(plot_color(get_linecolor(series, clims, i), get_linealpha(series, i))), :width => get_linewidth(series, i), :shape => if st == :steppre "vh" From a81178121f3152e5b374bf48e01a172956e041d3 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 24 Aug 2018 22:01:46 +0200 Subject: [PATCH 21/21] implement pyplot --- src/backends/pyplot.jl | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index d31a2b6e..5242e50c 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -436,12 +436,10 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) # handle zcolor and get c/cmap needs_colorbar = hascolorbar(sp) - extrakw = if needs_colorbar || is_2tuple(sp[:clims]) - vmin, vmax = get_clims(sp) - KW(:vmin => vmin, :vmax => vmax) - else - KW() - end + vmin, vmax = clims = get_clims(sp) + + # Dict to store extra kwargs + extrakw = KW(:vmin => vmin, :vmax => vmax) # holds references to any python object representing the matplotlib series handles = [] @@ -502,7 +500,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) handle = ax[:plot]((arg[rng] for arg in xyargs)...; label = i == 1 ? series[:label] : "", zorder = series[:series_plotindex], - color = py_color(get_linecolor(series, i), get_linealpha(series, i)), + color = py_color(get_linecolor(series, clims, i), get_linealpha(series, i)), linewidth = py_thickness_scale(plt, get_linewidth(series, i)), linestyle = py_linestyle(st, get_linestyle(series, i)), solid_capstyle = "round", @@ -544,7 +542,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) :scatter3d, :steppre, :steppost, :bar) markercolor = if any(typeof(series[arg]) <: AVec for arg in (:markercolor, :markeralpha)) || series[:marker_z] != nothing - py_color(plot_color.(get_markercolor.(series, eachindex(x)), get_markeralpha.(series, eachindex(x)))) + # py_color(plot_color.(get_markercolor.(series, clims, eachindex(x)), get_markeralpha.(series, eachindex(x)))) + [py_color(plot_color(get_markercolor(series, clims, i), get_markeralpha(series, i))) for i in eachindex(x)] else py_color(plot_color(series[:markercolor], series[:markeralpha])) end @@ -692,11 +691,6 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) elseif typeof(z) <: AbstractVector # tri-surface plot (http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#tri-surface-plots) - clims = sp[:clims] - if is_2tuple(clims) - isfinite(clims[1]) && (extrakw[:vmin] = clims[1]) - isfinite(clims[2]) && (extrakw[:vmax] = clims[2]) - end handle = ax[:plot_trisurf](x, y, z; label = series[:label], zorder = series[:series_plotindex], @@ -767,8 +761,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) path; label = series[:label], zorder = series[:series_plotindex], - edgecolor = py_color(get_linecolor(series, i), get_linealpha(series, i)), - facecolor = py_color(get_fillcolor(series, i), get_fillalpha(series, i)), + edgecolor = py_color(get_linecolor(series, clims, i), get_linealpha(series, i)), + facecolor = py_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)), linewidth = py_thickness_scale(plt, get_linewidth(series, i)), linestyle = py_linestyle(st, get_linestyle(series, i)), fill = true @@ -817,7 +811,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) handle = ax[f](args..., trues(n), false, py_fillstepstyle(st); zorder = series[:series_plotindex], - facecolor = py_color(get_fillcolor(series, i), get_fillalpha(series, i)), + facecolor = py_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)), linewidths = 0 ) push!(handles, handle) @@ -1227,6 +1221,7 @@ const _pyplot_legend_pos = KW( function py_add_legend(plt::Plot, sp::Subplot, ax) leg = sp[:legend] + clims = get_clims(sp) if leg != :none # gotta do this to ensure both axes are included labels = [] @@ -1236,19 +1231,19 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) # add a line/marker and a label push!(handles, if series[:seriestype] == :shape || series[:fillrange] != nothing pypatches[:Patch]( - edgecolor = py_color(get_linecolor(series), get_linealpha(series)), - facecolor = py_color(get_fillcolor(series), get_fillalpha(series)), + edgecolor = py_color(get_linecolor(series, clims), get_linealpha(series)), + facecolor = py_color(get_fillcolor(series, clims), get_fillalpha(series)), linewidth = py_thickness_scale(plt, clamp(get_linewidth(series), 0, 5)), linestyle = py_linestyle(series[:seriestype], get_linestyle(series)) ) elseif series[:seriestype] in (:path, :straightline) PyPlot.plt[:Line2D]((0,1),(0,0), - color = py_color(get_linecolor(series), get_linealpha(series)), + color = py_color(get_linecolor(series, clims), get_linealpha(series)), linewidth = py_thickness_scale(plt, clamp(get_linewidth(series), 0, 5)), linestyle = py_linestyle(:path, get_linestyle(series)), marker = py_marker(series[:markershape]), markeredgecolor = py_color(get_markerstrokecolor(series), get_markerstrokealpha(series)), - markerfacecolor = series[:marker_z] == nothing ? py_color(get_markercolor(series), get_markeralpha(series)) : py_color(series[:markercolor][0.5]) + markerfacecolor = series[:marker_z] == nothing ? py_color(get_markercolor(series, clims), get_markeralpha(series)) : py_color(series[:markercolor][0.5]) ) else series[:serieshandle][1]