Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
f0a3ca4314
@ -93,13 +93,13 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# write out html to view the gif... note the rand call which is a hack so the image doesn't get cached
|
# write out html to view the gif
|
||||||
function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif)
|
function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif)
|
||||||
ext = file_extension(agif.filename)
|
ext = file_extension(agif.filename)
|
||||||
write(io, if ext == "gif"
|
write(io, if ext == "gif"
|
||||||
"<img src=\"$(relpath(agif.filename))?$(rand())>\" />"
|
"<img src=\"$(relpath(agif.filename))\" />"
|
||||||
elseif ext in ("mov", "mp4")
|
elseif ext in ("mov", "mp4")
|
||||||
"<video controls><source src=\"$(relpath(agif.filename))?$(rand())>\" type=\"video/$ext\"></video>"
|
"<video controls><source src=\"$(relpath(agif.filename)) type=\"video/$ext\"></video>"
|
||||||
else
|
else
|
||||||
error("Cannot show animation with extension $ext: $agif")
|
error("Cannot show animation with extension $ext: $agif")
|
||||||
end)
|
end)
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
|
# https://github.com/sglyon/PlotlyJS.jl
|
||||||
# https://github.com/spencerlyon2/PlotlyJS.jl
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -50,23 +49,11 @@ end
|
|||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
function _show(io::IO, ::MIME"text/html", plt::Plot{PlotlyJSBackend})
|
_show(io::IO, ::MIME"text/html", plt::Plot{PlotlyJSBackend}) = show(io, MIME("text/html"), plt.o)
|
||||||
if isijulia() && !_use_remote[]
|
_show(io::IO, ::MIME"image/svg+xml", plt::Plot{PlotlyJSBackend}) = PlotlyJS.savefig(io, plt.o, format="svg")
|
||||||
write(io, PlotlyJS.html_body(PlotlyJS.JupyterPlot(plt.o)))
|
_show(io::IO, ::MIME"image/png", plt::Plot{PlotlyJSBackend}) = PlotlyJS.savefig(io, plt.o, format="png")
|
||||||
else
|
_show(io::IO, ::MIME"application/pdf", plt::Plot{PlotlyJSBackend}) = PlotlyJS.savefig(io, plt.o, format="pdf")
|
||||||
show(io, MIME("text/html"), plt.o)
|
_show(io::IO, ::MIME"image/eps", plt::Plot{PlotlyJSBackend}) = PlotlyJS.savefig(io, plt.o, format="eps")
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function plotlyjs_save_hack(io::IO, plt::Plot{PlotlyJSBackend}, ext::String)
|
|
||||||
tmpfn = tempname() * "." * ext
|
|
||||||
PlotlyJS.savefig(plt.o, tmpfn)
|
|
||||||
write(io, read(open(tmpfn)))
|
|
||||||
end
|
|
||||||
_show(io::IO, ::MIME"image/svg+xml", plt::Plot{PlotlyJSBackend}) = plotlyjs_save_hack(io, plt, "svg")
|
|
||||||
_show(io::IO, ::MIME"image/png", plt::Plot{PlotlyJSBackend}) = plotlyjs_save_hack(io, plt, "png")
|
|
||||||
_show(io::IO, ::MIME"application/pdf", plt::Plot{PlotlyJSBackend}) = plotlyjs_save_hack(io, plt, "pdf")
|
|
||||||
_show(io::IO, ::MIME"image/eps", plt::Plot{PlotlyJSBackend}) = plotlyjs_save_hack(io, plt, "eps")
|
|
||||||
|
|
||||||
function write_temp_html(plt::Plot{PlotlyJSBackend})
|
function write_temp_html(plt::Plot{PlotlyJSBackend})
|
||||||
filename = string(tempname(), ".html")
|
filename = string(tempname(), ".html")
|
||||||
|
|||||||
@ -589,9 +589,9 @@ Plots.@deps stepbins path
|
|||||||
wand_edges(x...) = (@warn("Load the StatPlots package in order to use :wand bins. Defaulting to :auto", once = true); :auto)
|
wand_edges(x...) = (@warn("Load the StatPlots package in order to use :wand bins. Defaulting to :auto", once = true); :auto)
|
||||||
|
|
||||||
function _auto_binning_nbins(vs::NTuple{N,AbstractVector}, dim::Integer; mode::Symbol = :auto) where N
|
function _auto_binning_nbins(vs::NTuple{N,AbstractVector}, dim::Integer; mode::Symbol = :auto) where N
|
||||||
_cl(x) = ceil(Int, NaNMath.max(x, one(x)))
|
_cl(x) = ceil(Int, max(x, one(x)))
|
||||||
_iqr(v) = (q = quantile(v, 0.75) - quantile(v, 0.25); q > 0 ? q : oftype(q, 1))
|
_iqr(v) = (q = quantile(v, 0.75) - quantile(v, 0.25); q > 0 ? q : oftype(q, 1))
|
||||||
_span(v) = ignorenan_maximum(v) - ignorenan_minimum(v)
|
_span(v) = maximum(v) - minimum(v)
|
||||||
|
|
||||||
n_samples = length(LinearIndices(first(vs)))
|
n_samples = length(LinearIndices(first(vs)))
|
||||||
|
|
||||||
@ -635,11 +635,19 @@ _hist_edges(vs::NTuple{N,AbstractVector}, binning::Union{Integer, Symbol, Abstra
|
|||||||
_hist_norm_mode(mode::Symbol) = mode
|
_hist_norm_mode(mode::Symbol) = mode
|
||||||
_hist_norm_mode(mode::Bool) = mode ? :pdf : :none
|
_hist_norm_mode(mode::Bool) = mode ? :pdf : :none
|
||||||
|
|
||||||
|
_filternans(vs::NTuple{1,AbstractVector}) = filter!.(isfinite, vs)
|
||||||
|
function _filternans(vs::NTuple{N,AbstractVector}) where N
|
||||||
|
_invertedindex(v, not) = [j for (i,j) in enumerate(v) if !(i ∈ not)]
|
||||||
|
nots = union(Set.(findall.(!isfinite, vs))...)
|
||||||
|
_invertedindex.(vs, Ref(nots))
|
||||||
|
end
|
||||||
|
|
||||||
function _make_hist(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing) where N
|
function _make_hist(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing) where N
|
||||||
edges = _hist_edges(vs, binning)
|
localvs = _filternans(vs)
|
||||||
|
edges = _hist_edges(localvs, binning)
|
||||||
h = float( weights == nothing ?
|
h = float( weights == nothing ?
|
||||||
StatsBase.fit(StatsBase.Histogram, vs, edges, closed = :left) :
|
StatsBase.fit(StatsBase.Histogram, localvs, edges, closed = :left) :
|
||||||
StatsBase.fit(StatsBase.Histogram, vs, StatsBase.Weights(weights), edges, closed = :left)
|
StatsBase.fit(StatsBase.Histogram, localvs, StatsBase.Weights(weights), edges, closed = :left)
|
||||||
)
|
)
|
||||||
normalize!(h, mode = _hist_norm_mode(normed))
|
normalize!(h, mode = _hist_norm_mode(normed))
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user