PyPlot fixes; test fixes
This commit is contained in:
parent
6ac312bd49
commit
cafac135a0
@ -207,6 +207,10 @@ function _create_plot(pkg::PyPlotPackage; kw...)
|
|||||||
w,h = map(px2inch, d[:size])
|
w,h = map(px2inch, d[:size])
|
||||||
bgcolor = getPyPlotColor(d[:background_color])
|
bgcolor = getPyPlotColor(d[:background_color])
|
||||||
wrap = PyPlotAxisWrapper(nothing, nothing, PyPlot.figure(; figsize = (w,h), facecolor = bgcolor, dpi = DPI, tight_layout = true), [])
|
wrap = PyPlotAxisWrapper(nothing, nothing, PyPlot.figure(; figsize = (w,h), facecolor = bgcolor, dpi = DPI, tight_layout = true), [])
|
||||||
|
|
||||||
|
if haskey(d, :linetype) && first(d[:linetype]) in _3dTypes # && isa(plt.o, PyPlotFigWrapper)
|
||||||
|
push!(wrap.kwargs, (:projection, "3d"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
plt = Plot(wrap, pkg, 0, d, Dict[])
|
plt = Plot(wrap, pkg, 0, d, Dict[])
|
||||||
@ -218,9 +222,9 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
d = Dict(kw)
|
d = Dict(kw)
|
||||||
|
|
||||||
lt = d[:linetype]
|
lt = d[:linetype]
|
||||||
if lt in _3dTypes # && isa(plt.o, PyPlotFigWrapper)
|
# if lt in _3dTypes # && isa(plt.o, PyPlotFigWrapper)
|
||||||
push!(plt.o.kwargs, (:projection, "3d"))
|
# push!(plt.o.kwargs, (:projection, "3d"))
|
||||||
end
|
# end
|
||||||
|
|
||||||
ax = getAxis(plt, d[:axis])
|
ax = getAxis(plt, d[:axis])
|
||||||
if !(lt in supportedTypes(pkg))
|
if !(lt in supportedTypes(pkg))
|
||||||
@ -249,7 +253,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
lt = d[:linetype]
|
# lt = d[:linetype]
|
||||||
extra_kwargs = Dict()
|
extra_kwargs = Dict()
|
||||||
|
|
||||||
plotfunc = getPyPlotFunction(plt, d[:axis], lt)
|
plotfunc = getPyPlotFunction(plt, d[:axis], lt)
|
||||||
@ -349,15 +353,16 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
handle = plotfunc(x, y, surf, extra_args...; extra_kwargs...)
|
handle = plotfunc(x, y, surf, extra_args...; extra_kwargs...)
|
||||||
if d[:fillrange] != nothing
|
if d[:fillrange] != nothing
|
||||||
extra_kwargs[:cmap] = getPyPlotColorMap(d[:fillcolor], d[:fillalpha])
|
extra_kwargs[:cmap] = getPyPlotColorMap(d[:fillcolor], d[:fillalpha])
|
||||||
|
delete!(extra_kwargs, :linewidths)
|
||||||
handle = ax[:contourf](x, y, surf, extra_args...; extra_kwargs...)
|
handle = ax[:contourf](x, y, surf, extra_args...; extra_kwargs...)
|
||||||
end
|
end
|
||||||
handle
|
handle
|
||||||
|
|
||||||
elseif lt in (:surface,:wireframe)
|
elseif lt in (:surface,:wireframe)
|
||||||
x, y, z = d[:x], d[:y], d[:z].surf
|
x, y, z = d[:x], d[:y], Array(d[:z])
|
||||||
if !ismatrix(x) || !ismatrix(y)
|
if !ismatrix(x) || !ismatrix(y)
|
||||||
x = repmat(x', length(y), 1)
|
x = repmat(x', length(y), 1)
|
||||||
y = repmat(y, 1, length(x))
|
y = repmat(y, 1, length(d[:x]))
|
||||||
z = z'
|
z = z'
|
||||||
end
|
end
|
||||||
plotfunc(x, y, z; extra_kwargs...)
|
plotfunc(x, y, z; extra_kwargs...)
|
||||||
|
|||||||
@ -231,6 +231,8 @@ end
|
|||||||
|
|
||||||
Surface(f::Function, x, y) = Surface(Float64[f(xi,yi) for xi in x, yi in y])
|
Surface(f::Function, x, y) = Surface(Float64[f(xi,yi) for xi in x, yi in y])
|
||||||
|
|
||||||
|
Base.Array(surf::Surface) = surf.surf
|
||||||
|
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
type OHLC{T<:Real}
|
type OHLC{T<:Real}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ function plot(args...; kw...)
|
|||||||
preprocessArgs!(d)
|
preprocessArgs!(d)
|
||||||
dumpdict(d, "After plot preprocessing")
|
dumpdict(d, "After plot preprocessing")
|
||||||
|
|
||||||
plotargs = getPlotArgs(pkg, d, 1)
|
plotargs = merge(d, getPlotArgs(pkg, d, 1))
|
||||||
dumpdict(plotargs, "Plot args")
|
dumpdict(plotargs, "Plot args")
|
||||||
plt = _create_plot(pkg; plotargs...) # create a new, blank plot
|
plt = _create_plot(pkg; plotargs...) # create a new, blank plot
|
||||||
|
|
||||||
|
|||||||
@ -174,7 +174,9 @@ function replaceAliases!(d::Dict, aliases::Dict)
|
|||||||
end
|
end
|
||||||
|
|
||||||
createSegments(z) = collect(repmat(z',2,1))[2:end]
|
createSegments(z) = collect(repmat(z',2,1))[2:end]
|
||||||
|
|
||||||
Base.first(c::Colorant) = c
|
Base.first(c::Colorant) = c
|
||||||
|
Base.first(x::Symbol) = x
|
||||||
|
|
||||||
|
|
||||||
sortedkeys(d::Dict) = sort(collect(keys(d)))
|
sortedkeys(d::Dict) = sort(collect(keys(d)))
|
||||||
@ -201,6 +203,7 @@ isscalar(::Any) = false
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ticksType{T<:Real,S<:Real}(ticks::@compat(Tuple{T,S})) = :limits
|
# ticksType{T<:Real,S<:Real}(ticks::@compat(Tuple{T,S})) = :limits
|
||||||
ticksType{T<:Real}(ticks::AVec{T}) = :ticks
|
ticksType{T<:Real}(ticks::AVec{T}) = :ticks
|
||||||
ticksType{T<:AVec,S<:AVec}(ticks::@compat(Tuple{T,S})) = :ticks_and_labels
|
ticksType{T<:AVec,S<:AVec}(ticks::@compat(Tuple{T,S})) = :ticks_and_labels
|
||||||
|
|||||||
@ -73,7 +73,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
|
|||||||
|
|
||||||
# first
|
# first
|
||||||
Plots._debugMode.on = debug
|
Plots._debugMode.on = debug
|
||||||
example = ExamplePlots.examples[idx]
|
example = ExamplePlots._examples[idx]
|
||||||
info("Testing plot: $pkg:$idx:$(example.header)")
|
info("Testing plot: $pkg:$idx:$(example.header)")
|
||||||
backend(pkg)
|
backend(pkg)
|
||||||
backend()
|
backend()
|
||||||
@ -88,7 +88,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
|
|||||||
end
|
end
|
||||||
|
|
||||||
# run the example
|
# run the example
|
||||||
# map(eval, PlotExamples.examples[idx].exprs)
|
# map(eval, PlotExamples._examples[idx].exprs)
|
||||||
|
|
||||||
# # save the png
|
# # save the png
|
||||||
# tmpfn = tempname() * ".png"
|
# tmpfn = tempname() * ".png"
|
||||||
@ -148,7 +148,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
|
|||||||
end
|
end
|
||||||
|
|
||||||
function image_comparison_facts(pkg::Symbol; skip = [], debug = false, sigma = [1,1], eps = 1e-2)
|
function image_comparison_facts(pkg::Symbol; skip = [], debug = false, sigma = [1,1], eps = 1e-2)
|
||||||
for i in 1:length(ExamplePlots.examples)
|
for i in 1:length(ExamplePlots._examples)
|
||||||
i in skip && continue
|
i in skip && continue
|
||||||
@fact image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success --> true
|
@fact image_comparison_tests(pkg, i, debug=debug, sigma=sigma, eps=eps) |> success --> true
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user