plotlyjs, pyplot and test fixes

This commit is contained in:
Daniel Schwabeneder 2018-09-02 22:28:34 +02:00
parent d3e1a423fd
commit 87c471c0f5
5 changed files with 56 additions and 42 deletions

View File

@ -347,16 +347,6 @@ function _initialize_backend(::GLVisualizeBackend; kw...)
end end
end end
# ------------------------------------------------------------------------------
# hdf5
function _initialize_backend(::HDF5Backend)
@eval Main begin
import HDF5
export HDF5
end
end
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# PGFPLOTS # PGFPLOTS
@ -371,11 +361,19 @@ end
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# plotlyjs # plotlyjs
function _initialize_backend(pkg::PlotlyJSBackend)
sym = backend_package_name(pkg)
@eval Main begin
import PlotlyJS, ORCA
export PlotlyJS
end
end
function add_backend_string(::PlotlyJSBackend) function add_backend_string(::PlotlyJSBackend)
""" """
using Pkg using Pkg
Pkg.add("PlotlyJS") Pkg.add(["PlotlyJS", "Blink"])
Pkg.add("Rsvg") Pkg.add(PackageSpec(url="https://github.com/sglyon/ORCA.jl.git", rev="master"))
import Blink import Blink
Blink.AtomShell.install() Blink.AtomShell.install()
""" """

View File

@ -12,7 +12,10 @@ const _plotlyjs_scale = _plotly_scale
function _create_backend_figure(plt::Plot{PlotlyJSBackend}) function _create_backend_figure(plt::Plot{PlotlyJSBackend})
if !isplotnull() && plt[:overwrite_figure] && isa(current().o, PlotlyJS.SyncPlot) if !isplotnull() && plt[:overwrite_figure] && isa(current().o, PlotlyJS.SyncPlot)
PlotlyJS.SyncPlot(PlotlyJS.Plot(), current().o.view) PlotlyJS.SyncPlot(PlotlyJS.Plot(),
events = current().o.events,
options = current().o.options,
)
else else
PlotlyJS.plot() PlotlyJS.plot()
end end

View File

@ -1064,7 +1064,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
ticks = sp[:framestyle] == :none ? nothing : get_ticks(axis) ticks = sp[:framestyle] == :none ? nothing : get_ticks(axis)
# don't show the 0 tick label for the origin framestyle # don't show the 0 tick label for the origin framestyle
if sp[:framestyle] == :origin && length(ticks) > 1 if sp[:framestyle] == :origin && length(ticks) > 1
ticks[2][ticks[1] .== 0] = "" ticks[2][ticks[1] .== 0] .= ""
end end
axis[:ticks] != :native ? py_set_ticks(ax, ticks, letter) : nothing axis[:ticks] != :native ? py_set_ticks(ax, ticks, letter) : nothing
pyaxis[:set_tick_params](direction = axis[:tick_direction] == :out ? "out" : "in") pyaxis[:set_tick_params](direction = axis[:tick_direction] == :out ? "out" : "in")

View File

@ -4,7 +4,6 @@ using Pkg
# ENV["PYTHON"] = "" # ENV["PYTHON"] = ""
to_add = [ to_add = [
PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"),
# PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"), # PackageSpec(url="https://github.com/JuliaStats/KernelDensity.jl.git"),
PackageSpec(name="PlotUtils", rev="master"), PackageSpec(name="PlotUtils", rev="master"),
PackageSpec(name="RecipesBase", rev="master"), PackageSpec(name="RecipesBase", rev="master"),
@ -17,12 +16,24 @@ to_add = [
] ]
if isinteractive() if isinteractive()
Pkg.develop(PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"))
append!(to_add, [ append!(to_add, [
PackageSpec(name="FileIO"), PackageSpec(name="FileIO"),
PackageSpec(name="ImageMagick"), PackageSpec(name="ImageMagick"),
PackageSpec(name="UnicodePlots"), PackageSpec(name="UnicodePlots"),
PackageSpec(name="VisualRegressionTests"), PackageSpec(name="VisualRegressionTests"),
PackageSpec(name="Gtk"),
# PlotlyJS:
# PackageSpec(name="PlotlyJS", rev="master"),
# PackageSpec(name="Blink"),
# PackageSpec(url="https://github.com/sglyon/ORCA.jl.git", rev="master"),
# PyPlot:
# PackageSpec(name="PyPlot"),
# PackageSpec(name="PyCall"),
# PackageSpec(name="LaTeXStrings"),
]) ])
else
push!(to_add, PackageSpec(url="https://github.com/JuliaPlots/PlotReferenceImages.jl.git"))
end end
Pkg.add(to_add) Pkg.add(to_add)

View File

@ -17,40 +17,42 @@ img_tol = isinteractive() ? 1e-2 : 10e-2
image_comparison_facts(:gr, tol=img_tol, skip = [25, 30]) image_comparison_facts(:gr, tol=img_tol, skip = [25, 30])
end end
# @static if isinteractive()
#@testset "PyPlot" begin # @testset "PyPlot" begin
# @test pyplot() == Plots.PyPlotBackend() # @test pyplot() == Plots.PyPlotBackend()
# @test backend() == Plots.PyPlotBackend() # @test backend() == Plots.PyPlotBackend()
# #
# image_comparison_facts(:pyplot, tol=img_tol) # image_comparison_facts(:pyplot, tol=img_tol, skip = [25, 30])
#end # end
# end
@testset "UnicodePlots" begin # @testset "UnicodePlots" begin
@test unicodeplots() == Plots.UnicodePlotsBackend() # @test unicodeplots() == Plots.UnicodePlotsBackend()
@test backend() == Plots.UnicodePlotsBackend() # @test backend() == Plots.UnicodePlotsBackend()
#
# lets just make sure it runs without error # # lets just make sure it runs without error
@test isa(plot(rand(10)), Plots.Plot) == true # @test isa(plot(rand(10)), Plots.Plot) == true
end # end
# The plotlyjs testimages return a connection error on travis: # The plotlyjs testimages return a connection error on travis:
# connect: connection refused (ECONNREFUSED) # connect: connection refused (ECONNREFUSED)
# @testset "PlotlyJS" begin @static if isinteractive()
# @test plotlyjs() == Plots.PlotlyJSBackend() @testset "PlotlyJS" begin
# @test backend() == Plots.PlotlyJSBackend() @test plotlyjs() == Plots.PlotlyJSBackend()
# @test backend() == Plots.PlotlyJSBackend()
# if Sys.islinux() && isinteractive()
# image_comparison_facts(:plotlyjs,
# skip=[
# 2, # animation (skipped for speed)
# 27, # (polar plots) takes very long / not working
# 31, # animation (skipped for speed)
# ],
# tol=img_tol)
# end
# end
image_comparison_facts(:plotlyjs,
skip=[
2, # animation (skipped for speed)
25,
27, # (polar plots) takes very long / not working
30,
31, # animation (skipped for speed)
],
tol=img_tol)
end
end
# InspectDR returns that error on travis: # InspectDR returns that error on travis:
# ERROR: LoadError: InitError: Cannot open display: # ERROR: LoadError: InitError: Cannot open display: