fixes for ticks
This commit is contained in:
parent
e8d4fd7aac
commit
0fdb48bda3
@ -518,6 +518,12 @@ function preprocessArgs!(d::Dict)
|
|||||||
processAxisArg(d, axisletter, arg)
|
processAxisArg(d, axisletter, arg)
|
||||||
end
|
end
|
||||||
delete!(d, asym)
|
delete!(d, asym)
|
||||||
|
|
||||||
|
# turn :labels into :ticks_and_labels
|
||||||
|
tsym = symbol(axisletter * "ticks")
|
||||||
|
if haskey(d, tsym) && ticksType(d[tsym]) == :labels
|
||||||
|
d[tsym] = (1:length(d[tsym]), d[tsym])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# handle line args
|
# handle line args
|
||||||
|
|||||||
@ -369,7 +369,7 @@ function addGadflyTicksGuide(gplt, ticks, isx::Bool)
|
|||||||
gfunc = isx ? Gadfly.Scale.x_discrete : Gadfly.Scale.y_discrete
|
gfunc = isx ? Gadfly.Scale.x_discrete : Gadfly.Scale.y_discrete
|
||||||
labelmap = Dict(zip(ticks...))
|
labelmap = Dict(zip(ticks...))
|
||||||
labelfunc = val -> labelmap[val]
|
labelfunc = val -> labelmap[val]
|
||||||
push!(gplt.scales, gfunc(levels = ticks[1], labels = labelfunc))
|
push!(gplt.scales, gfunc(levels = collect(ticks[1]), labels = labelfunc))
|
||||||
|
|
||||||
else
|
else
|
||||||
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
||||||
|
|||||||
@ -27,11 +27,6 @@ function _initialize_backend(::PlotlyPackage; kw...)
|
|||||||
# end borrowing (thanks :)
|
# end borrowing (thanks :)
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
# try
|
|
||||||
# include(joinpath(Pkg.dir("Plots"), "src", "backends", "plotly_blink.jl"))
|
|
||||||
# catch err
|
|
||||||
# warn("Error including PlotlyJS: $err\n Note: Will fall back to built-in display.")
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
# TODO: other initialization
|
# TODO: other initialization
|
||||||
end
|
end
|
||||||
|
|||||||
@ -493,7 +493,8 @@ function addPyPlotTicks(ax, ticks, isx::Bool)
|
|||||||
if ttype == :ticks
|
if ttype == :ticks
|
||||||
ax[isx ? :set_xticks : :set_yticks](ticks)
|
ax[isx ? :set_xticks : :set_yticks](ticks)
|
||||||
elseif ttype == :ticks_and_labels
|
elseif ttype == :ticks_and_labels
|
||||||
ax[isx ? :set_xticks : :set_yticks](ticks...)
|
ax[isx ? :set_xticks : :set_yticks](ticks[1])
|
||||||
|
ax[isx ? :set_xticklabels : :set_yticklabels](ticks[2])
|
||||||
else
|
else
|
||||||
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -206,6 +206,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<:AbstractString}(ticks::AVec{T}) = :labels
|
||||||
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
|
||||||
ticksType(ticks) = :invalid
|
ticksType(ticks) = :invalid
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,9 @@ using Plots, FactCheck
|
|||||||
default(size=(500,300))
|
default(size=(500,300))
|
||||||
|
|
||||||
|
|
||||||
|
# reference image directory setup
|
||||||
|
_refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg))
|
||||||
|
|
||||||
# TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that
|
# TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that
|
||||||
# is referenced in a button press callback (the button clicked callback will call notify() on that condition)
|
# is referenced in a button press callback (the button clicked callback will call notify() on that condition)
|
||||||
|
|
||||||
@ -37,23 +40,28 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
|
|||||||
png(fn)
|
png(fn)
|
||||||
end
|
end
|
||||||
|
|
||||||
# reference image directory setup
|
|
||||||
refdir = joinpath(Pkg.dir("ExamplePlots"), "test", "refimg", string(pkg))
|
|
||||||
try
|
try
|
||||||
run(`mkdir -p $refdir`)
|
run(`mkdir -p $(_refdir)`)
|
||||||
catch err
|
catch err
|
||||||
display(err)
|
display(err)
|
||||||
end
|
end
|
||||||
reffn = joinpath(refdir, "ref$idx.png")
|
reffn = joinpath(_refdir, "ref$idx.png")
|
||||||
|
|
||||||
# the test
|
# the test
|
||||||
vtest = VisualTest(func, reffn, idx)
|
vtest = VisualTest(func, reffn, idx)
|
||||||
test_images(vtest, popup=popup, sigma=sigma, eps=eps)
|
test_images(vtest, popup=popup, sigma=sigma, eps=eps)
|
||||||
end
|
end
|
||||||
|
|
||||||
function image_comparison_facts(pkg::Symbol; skip = [], debug = false, sigma = [1,1], eps = 1e-2)
|
function image_comparison_facts(pkg::Symbol;
|
||||||
|
skip = [], # skip these examples (int index)
|
||||||
|
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)
|
||||||
for i in 1:length(ExamplePlots._examples)
|
for i in 1:length(ExamplePlots._examples)
|
||||||
i in skip && continue
|
i in skip && continue
|
||||||
|
if only == nothing || i in only
|
||||||
@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
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user