Merge pull request #2754 from daschw/current-stable

Add missing commits
This commit is contained in:
Daniel Schwabeneder 2020-06-04 00:24:19 +02:00 committed by GitHub
commit 4d8ea50f69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 27 deletions

View File

@ -1,7 +1,7 @@
name = "Plots" name = "Plots"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
author = ["Tom Breloff (@tbreloff)"] author = ["Tom Breloff (@tbreloff)"]
version = "1.3.3" version = "1.3.6"
[deps] [deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@ -46,7 +46,7 @@ PlotUtils = "1"
RecipesBase = "1" RecipesBase = "1"
RecipesPipeline = "0.1.7" RecipesPipeline = "0.1.7"
Reexport = "0.2" Reexport = "0.2"
Requires = "0.5, 1" Requires = "1"
Showoff = "0.3.1" Showoff = "0.3.1"
StatsBase = "0.32, 0.33" StatsBase = "0.32, 0.33"
julia = "1" julia = "1"

View File

@ -945,8 +945,9 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
replaceAliases!(plotattributes, _keyAliases) replaceAliases!(plotattributes, _keyAliases)
# handle axis args common to all axis # handle axis args common to all axis
args = RecipesPipeline.pop_kw!(plotattributes, :axis, ()) args = wraptuple(RecipesPipeline.pop_kw!(plotattributes, :axis, ()))
for arg in wraptuple(args) showarg = wraptuple(RecipesPipeline.pop_kw!(plotattributes, :showaxis, ()))
for arg in wraptuple((args..., showarg...))
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
process_axis_arg!(plotattributes, arg, letter) process_axis_arg!(plotattributes, arg, letter)
end end

View File

@ -35,7 +35,6 @@ end
function process_axis_arg!(plotattributes::AKW, arg, letter = "") function process_axis_arg!(plotattributes::AKW, arg, letter = "")
T = typeof(arg) T = typeof(arg)
arg = get(_scaleAliases, arg, arg) arg = get(_scaleAliases, arg, arg)
if typeof(arg) <: Font if typeof(arg) <: Font
plotattributes[Symbol(letter,:tickfont)] = arg plotattributes[Symbol(letter,:tickfont)] = arg
plotattributes[Symbol(letter,:guidefont)] = arg plotattributes[Symbol(letter,:guidefont)] = arg

View File

@ -661,6 +661,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
handle = ax."contourf"(x, y, z, levelargs...; handle = ax."contourf"(x, y, z, levelargs...;
label = series[:label], label = series[:label],
zorder = series[:series_plotindex] + 0.5, zorder = series[:series_plotindex] + 0.5,
alpha = series[:fillalpha],
extrakw... extrakw...
) )
push!(handles, handle) push!(handles, handle)

View File

@ -29,49 +29,41 @@ function __init__()
@require HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" begin @require HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" begin
fn = joinpath(@__DIR__, "backends", "hdf5.jl") fn = joinpath(@__DIR__, "backends", "hdf5.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require InspectDR = "d0351b0e-4b05-5898-87b3-e2a8edfddd1d" begin @require InspectDR = "d0351b0e-4b05-5898-87b3-e2a8edfddd1d" begin
fn = joinpath(@__DIR__, "backends", "inspectdr.jl") fn = joinpath(@__DIR__, "backends", "inspectdr.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require PGFPlots = "3b7a836e-365b-5785-a47d-02c71176b4aa" begin @require PGFPlots = "3b7a836e-365b-5785-a47d-02c71176b4aa" begin
fn = joinpath(@__DIR__, "backends", "deprecated", "pgfplots.jl") fn = joinpath(@__DIR__, "backends", "deprecated", "pgfplots.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require ORCA = "47be7bcc-f1a6-5447-8b36-7eeeff7534fd" begin @require ORCA = "47be7bcc-f1a6-5447-8b36-7eeeff7534fd" begin
fn = joinpath(@__DIR__, "backends", "orca.jl") fn = joinpath(@__DIR__, "backends", "orca.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" begin @require PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" begin
fn = joinpath(@__DIR__, "backends", "pgfplotsx.jl") fn = joinpath(@__DIR__, "backends", "pgfplotsx.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" begin @require PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" begin
fn = joinpath(@__DIR__, "backends", "plotlyjs.jl") fn = joinpath(@__DIR__, "backends", "plotlyjs.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" begin @require PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" begin
fn = joinpath(@__DIR__, "backends", "pyplot.jl") fn = joinpath(@__DIR__, "backends", "pyplot.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" begin @require UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" begin
fn = joinpath(@__DIR__, "backends", "unicodeplots.jl") fn = joinpath(@__DIR__, "backends", "unicodeplots.jl")
include(fn) include(fn)
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
end end
@require IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" begin @require IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" begin

View File

@ -112,7 +112,7 @@ end
@recipe function f(::Type{Val{:hline}}, x, y, z) @recipe function f(::Type{Val{:hline}}, x, y, z)
n = length(y) n = length(y)
newx = repeat(Float64[-1, 1, NaN], n) newx = repeat(Float64[1, 2, NaN], n)
newy = vec(Float64[yi for i = 1:3, yi in y]) newy = vec(Float64[yi for i = 1:3, yi in y])
x := newx x := newx
y := newy y := newy
@ -124,7 +124,7 @@ end
@recipe function f(::Type{Val{:vline}}, x, y, z) @recipe function f(::Type{Val{:vline}}, x, y, z)
n = length(y) n = length(y)
newx = vec(Float64[yi for i = 1:3, yi in y]) newx = vec(Float64[yi for i = 1:3, yi in y])
newy = repeat(Float64[-1, 1, NaN], n) newy = repeat(Float64[1, 2, NaN], n)
x := newx x := newx
y := newy y := newy
seriestype := :straightline seriestype := :straightline

View File

@ -420,7 +420,7 @@ ylims(sp_idx::Int = 1) = ylims(current(), sp_idx)
zlims(sp_idx::Int = 1) = zlims(current(), sp_idx) zlims(sp_idx::Int = 1) = zlims(current(), sp_idx)
# These functions return an operator for use in `get_clims(::Seres, op)` # These functions return an operator for use in `get_clims(::Seres, op)`
process_clims(lims::NTuple{2,<:Number}) = (zlims -> ifelse.(isfinite.(lims), lims, zlims)) ignorenan_extrema process_clims(lims::Tuple{<:Number,<:Number}) = (zlims -> ifelse.(isfinite.(lims), lims, zlims)) ignorenan_extrema
process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema
# don't specialize on ::Function otherwise python functions won't work # don't specialize on ::Function otherwise python functions won't work
process_clims(f) = f process_clims(f) = f
@ -1079,10 +1079,21 @@ end
function straightline_data(series, expansion_factor = 1) function straightline_data(series, expansion_factor = 1)
sp = series[:subplot] sp = series[:subplot]
xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp)) xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp))
x, y = series[:x], series[:y]
# handle axes scales
xscale = sp[:xaxis][:scale]
xf = RecipesPipeline.scale_func(xscale)
xinvf = RecipesPipeline.inverse_scale_func(xscale)
yscale = sp[:yaxis][:scale]
yf = RecipesPipeline.scale_func(yscale)
yinvf = RecipesPipeline.inverse_scale_func(yscale)
xl, yl = xf.(xl), yf.(yl)
x, y = xf.(series[:x]), yf.(series[:y])
n = length(x) n = length(x)
if n == 2
return straightline_data(xl, yl, x, y, expansion_factor) xdata, ydata = if n == 2
straightline_data(xl, yl, x, y, expansion_factor)
else else
k, r = divrem(n, 3) k, r = divrem(n, 3)
if r == 0 if r == 0
@ -1091,11 +1102,13 @@ function straightline_data(series, expansion_factor = 1)
inds = (3 * i - 2):(3 * i - 1) inds = (3 * i - 2):(3 * i - 1)
xdata[inds], ydata[inds] = straightline_data(xl, yl, x[inds], y[inds], expansion_factor) xdata[inds], ydata[inds] = straightline_data(xl, yl, x[inds], y[inds], expansion_factor)
end end
return xdata, ydata xdata, ydata
else else
error("Misformed data. `straightline_data` either accepts vectors of length 2 or 3k. The provided series has length $n") error("Misformed data. `straightline_data` either accepts vectors of length 2 or 3k. The provided series has length $n")
end end
end end
return xinvf.(xdata), yinvf.(ydata)
end end
function straightline_data(xl, yl, x, y, expansion_factor = 1) function straightline_data(xl, yl, x, y, expansion_factor = 1)
@ -1127,20 +1140,28 @@ end
function shape_data(series, expansion_factor = 1) function shape_data(series, expansion_factor = 1)
sp = series[:subplot] sp = series[:subplot]
xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp)) xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp))
# handle axes scales
xscale = sp[:xaxis][:scale]
xf = RecipesPipeline.scale_func(xscale)
xinvf = RecipesPipeline.inverse_scale_func(xscale)
yscale = sp[:yaxis][:scale]
yf = RecipesPipeline.scale_func(yscale)
yinvf = RecipesPipeline.inverse_scale_func(yscale)
x, y = copy(series[:x]), copy(series[:y]) x, y = copy(series[:x]), copy(series[:y])
factor = 100
for i in eachindex(x) for i in eachindex(x)
if x[i] == -Inf if x[i] == -Inf
x[i] = xl[1] - expansion_factor * (xl[2] - xl[1]) x[i] = xinvf(xf(xl[1]) - expansion_factor * (xf(xl[2]) - xf(xl[1])))
elseif x[i] == Inf elseif x[i] == Inf
x[i] = xl[2] + expansion_factor * (xl[2] - xl[1]) x[i] = xinvf(xf(xl[2]) + expansion_factor * (xf(xl[2]) - xf(xl[1])))
end end
end end
for i in eachindex(y) for i in eachindex(y)
if y[i] == -Inf if y[i] == -Inf
y[i] = yl[1] - expansion_factor * (yl[2] - yl[1]) y[i] = yinvf(yf(yl[1]) - expansion_factor * (yf(yl[2]) - yf(yl[1])))
elseif y[i] == Inf elseif y[i] == Inf
y[i] = yl[2] + expansion_factor * (yl[2] - yl[1]) y[i] = yinvf(yf(yl[2]) + expansion_factor * (yf(yl[2]) - yf(yl[1])))
end end
end end
return x, y return x, y

View File

@ -9,6 +9,7 @@ using LibGit2
using GeometryTypes using GeometryTypes
using Dates using Dates
include("test_axes.jl")
include("test_hdf5plots.jl") include("test_hdf5plots.jl")
include("test_pgfplotsx.jl") include("test_pgfplotsx.jl")
@ -178,4 +179,9 @@ end
@test isequal(collect(zip(Plots.unzip(z)...)), z) @test isequal(collect(zip(Plots.unzip(z)...)), z)
@test isequal(collect(zip(Plots.unzip(GeometryTypes.Point.(z))...)), z) @test isequal(collect(zip(Plots.unzip(GeometryTypes.Point.(z))...)), z)
end end
op1 = Plots.process_clims((1.0, 2.0))
op2 = Plots.process_clims((1, 2.0))
data = randn(100, 100)
@test op1(data) == op2(data)
@test Plots.process_clims(nothing) == Plots.process_clims(missing) == Plots.process_clims(:auto)
end end

14
test/test_axes.jl Normal file
View File

@ -0,0 +1,14 @@
using Plots, Test
@testset "Showaxis" begin
for value in Plots._allShowaxisArgs
@test plot(1:5, showaxis = value)[1][:yaxis][:showaxis] isa Bool
end
@test plot(1:5, showaxis = :y)[1][:yaxis][:showaxis] == true
@test plot(1:5, showaxis = :y)[1][:xaxis][:showaxis] == false
end
@testset "Magic axis" begin
@test plot(1, axis=nothing)[1][:xaxis][:ticks] == []
@test plot(1, axis=nothing)[1][:yaxis][:ticks] == []
end # testset