Fix deprecations

This commit is contained in:
femtocleaner[bot] 2018-06-30 23:15:27 +00:00
parent 9cf3036ab5
commit d68829820b
28 changed files with 130 additions and 125 deletions

2
deps/build.jl vendored
View File

@ -3,6 +3,6 @@
local_fn = joinpath(dirname(@__FILE__), "plotly-latest.min.js") local_fn = joinpath(dirname(@__FILE__), "plotly-latest.min.js")
if !isfile(local_fn) if !isfile(local_fn)
info("Cannot find deps/plotly-latest.min.js... downloading latest version.") @info("Cannot find deps/plotly-latest.min.js... downloading latest version.")
download("https://cdn.plot.ly/plotly-latest.min.js", local_fn) download("https://cdn.plot.ly/plotly-latest.min.js", local_fn)
end end

View File

@ -188,7 +188,7 @@ const _allGridSyms = [:x, :y, :z,
:all, :both, :on, :yes, :show, :all, :both, :on, :yes, :show,
:none, :off, :no, :hide] :none, :off, :no, :hide]
const _allGridArgs = [_allGridSyms; string.(_allGridSyms); nothing] const _allGridArgs = [_allGridSyms; string.(_allGridSyms); nothing]
hasgrid(arg::Void, letter) = false hasgrid(arg::Nothing, letter) = false
hasgrid(arg::Bool, letter) = arg hasgrid(arg::Bool, letter) = arg
function hasgrid(arg::Symbol, letter) function hasgrid(arg::Symbol, letter)
if arg in _allGridSyms if arg in _allGridSyms
@ -206,7 +206,7 @@ const _allShowaxisSyms = [:x, :y, :z,
:all, :both, :on, :yes, :show, :all, :both, :on, :yes, :show,
:off, :no, :hide] :off, :no, :hide]
const _allShowaxisArgs = [_allGridSyms; string.(_allGridSyms)] const _allShowaxisArgs = [_allGridSyms; string.(_allGridSyms)]
showaxis(arg::Void, letter) = false showaxis(arg::Nothing, letter) = false
showaxis(arg::Bool, letter) = arg showaxis(arg::Bool, letter) = arg
function showaxis(arg::Symbol, letter) function showaxis(arg::Symbol, letter)
if arg in _allGridSyms if arg in _allGridSyms
@ -654,6 +654,7 @@ function handleColors!(d::KW, arg, csym::Symbol)
d[csym] = c d[csym] = c
end end
return true return true
catch
end end
false false
end end
@ -1131,7 +1132,7 @@ function convertLegendValue(val::Symbol)
end end
end end
convertLegendValue(val::Bool) = val ? :best : :none convertLegendValue(val::Bool) = val ? :best : :none
convertLegendValue(val::Void) = :none convertLegendValue(val::Nothing) = :none
convertLegendValue(v::Tuple{S,T}) where {S<:Real, T<:Real} = v convertLegendValue(v::Tuple{S,T}) where {S<:Real, T<:Real} = v
convertLegendValue(v::AbstractArray) = map(convertLegendValue, v) convertLegendValue(v::AbstractArray) = map(convertLegendValue, v)

View File

@ -251,7 +251,7 @@ function get_ticks(axis::Axis)
# discrete ticks... # discrete ticks...
n = length(dvals) n = length(dvals)
rng = if ticks == :auto rng = if ticks == :auto
Int[round(Int,i) for i in linspace(1, n, 15)] Int[round(Int,i) for i in range(1, stop=n, length=15)]
else # if ticks == :all else # if ticks == :all
1:n 1:n
end end
@ -265,7 +265,7 @@ function get_ticks(axis::Axis)
end end
elseif typeof(ticks) <: Union{AVec, Int} elseif typeof(ticks) <: Union{AVec, Int}
if !isempty(dvals) && typeof(ticks) <: Int if !isempty(dvals) && typeof(ticks) <: Int
rng = Int[round(Int,i) for i in linspace(1, length(dvals), ticks)] rng = Int[round(Int,i) for i in range(1, stop=length(dvals), length=ticks)]
axis[:continuous_values][rng], dvals[rng] axis[:continuous_values][rng], dvals[rng]
else else
# override ticks, but get the labels # override ticks, but get the labels
@ -310,7 +310,7 @@ function expand_extrema!(axis::Axis, v::Number)
end end
# these shouldn't impact the extrema # these shouldn't impact the extrema
expand_extrema!(axis::Axis, ::Void) = axis[:extrema] expand_extrema!(axis::Axis, ::Nothing) = axis[:extrema]
expand_extrema!(axis::Axis, ::Bool) = axis[:extrema] expand_extrema!(axis::Axis, ::Bool) = axis[:extrema]

View File

@ -80,7 +80,7 @@ function _initialize_backend(::GLVisualizeBackend; kw...)
is_marker_supported(::GLVisualizeBackend, shape::GLVisualize.AllPrimitives) = true is_marker_supported(::GLVisualizeBackend, shape::GLVisualize.AllPrimitives) = true
is_marker_supported(::GLVisualizeBackend, shape::Union{Vector{Matrix{C}}, Matrix{C}}) where {C<:Colorant} = true is_marker_supported(::GLVisualizeBackend, shape::Union{Vector{Matrix{C}}, Matrix{C}}) where {C<:Colorant} = true
is_marker_supported(::GLVisualizeBackend, shape::Shape) = true is_marker_supported(::GLVisualizeBackend, shape::Shape) = true
const GL = Plots GL = Plots
end end
end end
@ -397,7 +397,7 @@ function gappy(x, ps)
return last(ps) - x return last(ps) - x
end end
function ticks(points, resolution) function ticks(points, resolution)
Float16[gappy(x, points) for x = linspace(first(points),last(points), resolution)] Float16[gappy(x, points) for x = range(first(points), stop=last(points), length=resolution)]
end end
@ -901,12 +901,12 @@ function gl_boxplot(d, kw_args)
# filter y # filter y
values = y[filter(i -> _cycle(x,i) == glabel, 1:length(y))] values = y[filter(i -> _cycle(x,i) == glabel, 1:length(y))]
# compute quantiles # compute quantiles
q1,q2,q3,q4,q5 = quantile(values, linspace(0,1,5)) q1,q2,q3,q4,q5 = quantile(values, range(0, stop=1, length=5))
# notch # notch
n = Plots.notch_width(q2, q4, length(values)) n = Plots.notch_width(q2, q4, length(values))
# warn on inverted notches? # warn on inverted notches?
if notch && !warning && ( (q2>(q3-n)) || (q4<(q3+n)) ) if notch && !warning && ( (q2>(q3-n)) || (q4<(q3+n)) )
warn("Boxplot's notch went outside hinges. Set notch to false.") @warn("Boxplot's notch went outside hinges. Set notch to false.")
warning = true # Show the warning only one time warning = true # Show the warning only one time
end end
@ -1331,7 +1331,7 @@ end
function gl_surface(x,y,z, kw_args) function gl_surface(x,y,z, kw_args)
if isa(x, Range) && isa(y, Range) if isa(x, AbstractRange) && isa(y, AbstractRange)
main = z main = z
kw_args[:ranges] = (x, y) kw_args[:ranges] = (x, y)
else else
@ -1347,7 +1347,7 @@ function gl_surface(x,y,z, kw_args)
if get(kw_args, :wireframe, false) if get(kw_args, :wireframe, false)
points = map(Point3f0, zip(vec(x), vec(y), vec(z))) points = map(Point3f0, zip(vec(x), vec(y), vec(z)))
faces = Cuint[] faces = Cuint[]
idx = (i,j) -> sub2ind(size(z), i, j) - 1 idx = (i,j) -> CartesianIndices(size(z), i, j) - 1
for i=1:size(z,1), j=1:size(z,2) for i=1:size(z,1), j=1:size(z,2)
i < size(z,1) && push!(faces, idx(i, j), idx(i+1, j)) i < size(z,1) && push!(faces, idx(i, j), idx(i+1, j))

View File

@ -144,7 +144,7 @@ gr_set_fillcolor(c) = GR.setfillcolorind(gr_getcolorind(_cycle(c,1)))
gr_set_markercolor(c) = GR.setmarkercolorind(gr_getcolorind(_cycle(c,1))) gr_set_markercolor(c) = GR.setmarkercolorind(gr_getcolorind(_cycle(c,1)))
gr_set_textcolor(c) = GR.settextcolorind(gr_getcolorind(_cycle(c,1))) gr_set_textcolor(c) = GR.settextcolorind(gr_getcolorind(_cycle(c,1)))
gr_set_transparency(α::Real) = GR.settransparency(clamp(α, 0, 1)) gr_set_transparency(α::Real) = GR.settransparency(clamp(α, 0, 1))
function gr_set_transparency(::Void) end function gr_set_transparency(::Nothing) end
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
@ -485,7 +485,7 @@ function gr_colorbar(sp::Subplot, clims)
xmin, xmax = gr_xy_axislims(sp)[1:2] xmin, xmax = gr_xy_axislims(sp)[1:2]
gr_set_viewport_cmap(sp) gr_set_viewport_cmap(sp)
l = zeros(Int32, 1, 256) l = zeros(Int32, 1, 256)
l[1,:] = Int[round(Int, _i) for _i in linspace(1000, 1255, 256)] l[1,:] = Int[round(Int, _i) for _i in range(1000, stop=1255, length=256)]
GR.setscale(0) GR.setscale(0)
GR.setwindow(xmin, xmax, clims[1], clims[2]) GR.setwindow(xmin, xmax, clims[1], clims[2])
GR.cellarray(xmin, xmax, clims[2], clims[1], 1, length(l), l) GR.cellarray(xmin, xmax, clims[2], clims[1], 1, length(l), l)
@ -531,7 +531,7 @@ const _gr_gradient_alpha = ones(256)
function gr_set_gradient(c) function gr_set_gradient(c)
grad = isa(c, ColorGradient) ? c : cgrad() grad = isa(c, ColorGradient) ? c : cgrad()
for (i,z) in enumerate(linspace(0, 1, 256)) for (i,z) in enumerate(range(0, stop=1, length=256))
c = grad[z] c = grad[z]
GR.setcolorrep(999+i, red(c), green(c), blue(c)) GR.setcolorrep(999+i, red(c), green(c), blue(c))
_gr_gradient_alpha[i] = alpha(c) _gr_gradient_alpha[i] = alpha(c)
@ -718,7 +718,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
for ax in (sp[:xaxis], sp[:yaxis]) for ax in (sp[:xaxis], sp[:yaxis])
v = series[ax[:letter]] v = series[ax[:letter]]
if diff(collect(extrema(diff(v))))[1] > 1e-6*std(v) if diff(collect(extrema(diff(v))))[1] > 1e-6*std(v)
warn("GR: heatmap only supported with equally spaced data.") @warn("GR: heatmap only supported with equally spaced data.")
end end
end end
x, y = heatmap_edges(series[:x], sp[:xaxis][:scale]), heatmap_edges(series[:y], sp[:yaxis][:scale]) x, y = heatmap_edges(series[:x], sp[:xaxis][:scale]), heatmap_edges(series[:y], sp[:yaxis][:scale])
@ -1051,7 +1051,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if typeof(series[:levels]) <: AbstractArray if typeof(series[:levels]) <: AbstractArray
h = series[:levels] h = series[:levels]
else else
h = series[:levels] > 1 ? linspace(zmin, zmax, series[:levels]) : [(zmin + zmax) / 2] h = series[:levels] > 1 ? range(zmin, stop=zmax, length=series[:levels]) : [(zmin + zmax) / 2]
end end
if series[:fillrange] != nothing if series[:fillrange] != nothing
GR.surface(x, y, z, GR.OPTION_CELL_ARRAY) GR.surface(x, y, z, GR.OPTION_CELL_ARRAY)
@ -1379,7 +1379,7 @@ for (mime, fmt) in _gr_mimeformats
ENV["GKS_FILEPATH"] = filepath ENV["GKS_FILEPATH"] = filepath
gr_display(plt, $fmt) gr_display(plt, $fmt)
GR.emergencyclosegks() GR.emergencyclosegks()
write(io, readstring(filepath)) write(io, read(filepath, String))
rm(filepath) rm(filepath)
if env != "0" if env != "0"
ENV["GKSwstype"] = env ENV["GKSwstype"] = env

View File

@ -39,7 +39,7 @@ struct HDF5PlotNative; end #Indentifies a data element that can natively be hand
struct HDF5CTuple; end #Identifies a "complex" tuple structure struct HDF5CTuple; end #Identifies a "complex" tuple structure
mutable struct HDF5Plot_PlotRef mutable struct HDF5Plot_PlotRef
ref::Union{Plot, Void} ref::Union{Plot, Nothing}
end end
@ -146,9 +146,9 @@ function _initialize_backend(::HDF5Backend)
export HDF5 export HDF5
if length(HDF5PLOT_MAP_TELEM2STR) < 1 if length(HDF5PLOT_MAP_TELEM2STR) < 1
#Possible element types of high-level data types: #Possible element types of high-level data types:
const telem2str = Dict{String, Type}( telem2str = Dict{String, Type}(
"NATIVE" => HDF5PlotNative, "NATIVE" => HDF5PlotNative,
"VOID" => Void, "VOID" => Nothing,
"BOOL" => Bool, "BOOL" => Bool,
"SYMBOL" => Symbol, "SYMBOL" => Symbol,
"TUPLE" => Tuple, "TUPLE" => Tuple,
@ -315,9 +315,9 @@ function _hdf5plot_gwrite(grp, k::String, v::Array{Any})
warn("Cannot write Array: $k=$v") warn("Cannot write Array: $k=$v")
end end
=# =#
function _hdf5plot_gwrite(grp, k::String, v::Void) function _hdf5plot_gwrite(grp, k::String, v::Nothing)
grp[k] = 0 grp[k] = 0
_hdf5plot_writetype(grp, k, Void) _hdf5plot_writetype(grp, k, Nothing)
end end
function _hdf5plot_gwrite(grp, k::String, v::Bool) function _hdf5plot_gwrite(grp, k::String, v::Bool)
grp[k] = Int(v) grp[k] = Int(v)
@ -344,7 +344,7 @@ end
function _hdf5plot_gwrite(grp, k::String, d::Dict) function _hdf5plot_gwrite(grp, k::String, d::Dict)
# warn("Cannot write dict: $k=$d") # warn("Cannot write dict: $k=$d")
end end
function _hdf5plot_gwrite(grp, k::String, v::Range) function _hdf5plot_gwrite(grp, k::String, v::AbstractRange)
_hdf5plot_gwrite(grp, k, collect(v)) #For now _hdf5plot_gwrite(grp, k, collect(v)) #For now
end end
function _hdf5plot_gwrite(grp, k::String, v::ARGB{N0f8}) function _hdf5plot_gwrite(grp, k::String, v::ARGB{N0f8})
@ -365,7 +365,7 @@ function _hdf5plot_gwritearray(grp, k::String, v::Array{T}) where T
sz = size(v) sz = size(v)
for iter in eachindex(v) for iter in eachindex(v)
coord = ind2sub(sz, iter) coord = LinearIndices(sz, iter)
elem = v[iter] elem = v[iter]
idxstr = join(coord, "_") idxstr = join(coord, "_")
_hdf5plot_gwrite(vgrp, "v$idxstr", v[iter]) _hdf5plot_gwrite(vgrp, "v$idxstr", v[iter])
@ -485,7 +485,7 @@ function _hdf5plot_readcount(grp) #Read directly from group
end end
_hdf5plot_convert(T::Type{HDF5PlotNative}, v) = v _hdf5plot_convert(T::Type{HDF5PlotNative}, v) = v
_hdf5plot_convert(T::Type{Void}, v) = nothing _hdf5plot_convert(T::Type{Nothing}, v) = nothing
_hdf5plot_convert(T::Type{Bool}, v) = (v!=0) _hdf5plot_convert(T::Type{Bool}, v) = (v!=0)
_hdf5plot_convert(T::Type{Symbol}, v) = Symbol(v) _hdf5plot_convert(T::Type{Symbol}, v) = Symbol(v)
_hdf5plot_convert(T::Type{Tuple}, v) = tuple(v...) #With Vector{T<:Number} _hdf5plot_convert(T::Type{Tuple}, v) = tuple(v...) #With Vector{T<:Number}
@ -530,7 +530,7 @@ function _hdf5plot_read(grp, k::String, T::Type{Array}, dtid) #ANY
result = Array{Any}(sz) result = Array{Any}(sz)
for iter in eachindex(result) for iter in eachindex(result)
coord = ind2sub(sz, iter) coord = LinearIndices(sz, iter)
idxstr = join(coord, "_") idxstr = join(coord, "_")
result[iter] = _hdf5plot_read(grp, "v$idxstr") result[iter] = _hdf5plot_read(grp, "v$idxstr")
end end

View File

@ -90,24 +90,24 @@ end
# py_marker(markers::AVec) = map(py_marker, markers) # py_marker(markers::AVec) = map(py_marker, markers)
function _inspectdr_mapglyph(markers::AVec) function _inspectdr_mapglyph(markers::AVec)
warn("Vectors of markers are currently unsupported in InspectDR.") @warn("Vectors of markers are currently unsupported in InspectDR.")
_inspectdr_mapglyph(markers[1]) _inspectdr_mapglyph(markers[1])
end end
_inspectdr_mapglyphsize(v::Real) = v _inspectdr_mapglyphsize(v::Real) = v
function _inspectdr_mapglyphsize(v::Vector) function _inspectdr_mapglyphsize(v::Vector)
warn("Vectors of marker sizes are currently unsupported in InspectDR.") @warn("Vectors of marker sizes are currently unsupported in InspectDR.")
_inspectdr_mapglyphsize(v[1]) _inspectdr_mapglyphsize(v[1])
end end
_inspectdr_mapcolor(v::Colorant) = v _inspectdr_mapcolor(v::Colorant) = v
function _inspectdr_mapcolor(g::PlotUtils.ColorGradient) function _inspectdr_mapcolor(g::PlotUtils.ColorGradient)
warn("Color gradients are currently unsupported in InspectDR.") @warn("Color gradients are currently unsupported in InspectDR.")
#Pick middle color: #Pick middle color:
_inspectdr_mapcolor(g.colors[div(1+end,2)]) _inspectdr_mapcolor(g.colors[div(1+end,2)])
end end
function _inspectdr_mapcolor(v::AVec) function _inspectdr_mapcolor(v::AVec)
warn("Vectors of colors are currently unsupported in InspectDR.") @warn("Vectors of colors are currently unsupported in InspectDR.")
#Pick middle color: #Pick middle color:
_inspectdr_mapcolor(v[div(1+end,2)]) _inspectdr_mapcolor(v[div(1+end,2)])
end end
@ -166,13 +166,13 @@ function _initialize_backend(::InspectDRBackend; kw...)
export InspectDR export InspectDR
#Glyph used when plotting "Shape"s: #Glyph used when plotting "Shape"s:
const INSPECTDR_GLYPH_SHAPE = InspectDR.GlyphPolyline( INSPECTDR_GLYPH_SHAPE = InspectDR.GlyphPolyline(
2*InspectDR.GLYPH_SQUARE.x, InspectDR.GLYPH_SQUARE.y 2*InspectDR.GLYPH_SQUARE.x, InspectDR.GLYPH_SQUARE.y
) )
mutable struct InspecDRPlotRef mutable struct InspecDRPlotRef
mplot::Union{Void, InspectDR.Multiplot} mplot::Union{Nothing, InspectDR.Multiplot}
gui::Union{Void, InspectDR.GtkPlot} gui::Union{Nothing, InspectDR.GtkPlot}
end end
_inspectdr_getmplot(::Any) = nothing _inspectdr_getmplot(::Any) = nothing
@ -347,8 +347,8 @@ end
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
function _inspectdr_setupsubplot(sp::Subplot{InspectDRBackend}) function _inspectdr_setupsubplot(sp::Subplot{InspectDRBackend})
const plot = sp.o plot = sp.o
const strip = plot.strips[1] #Only 1 strip supported with Plots.jl strip = plot.strips[1] #Only 1 strip supported with Plots.jl
xaxis = sp[:xaxis]; yaxis = sp[:yaxis] xaxis = sp[:xaxis]; yaxis = sp[:yaxis]
xgrid_show = xaxis[:grid] xgrid_show = xaxis[:grid]
@ -406,7 +406,7 @@ end
# called just before updating layout bounding boxes... in case you need to prep # called just before updating layout bounding boxes... in case you need to prep
# for the calcs # for the calcs
function _before_layout_calcs(plt::Plot{InspectDRBackend}) function _before_layout_calcs(plt::Plot{InspectDRBackend})
const mplot = _inspectdr_getmplot(plt.o) mplot = _inspectdr_getmplot(plt.o)
if nothing == mplot; return; end if nothing == mplot; return; end
mplot.title = plt[:plot_title] mplot.title = plt[:plot_title]
@ -506,7 +506,7 @@ const _inspectdr_mimeformats_nodpi = Dict(
# "application/postscript" => "ps", #TODO: support once Cairo supports PSSurface # "application/postscript" => "ps", #TODO: support once Cairo supports PSSurface
"application/pdf" => "pdf" "application/pdf" => "pdf"
) )
_inspectdr_show(io::IO, mime::MIME, ::Void, w, h) = _inspectdr_show(io::IO, mime::MIME, ::Nothing, w, h) =
throw(ErrorException("Cannot show(::IO, ...) plot - not yet generated")) throw(ErrorException("Cannot show(::IO, ...) plot - not yet generated"))
function _inspectdr_show(io::IO, mime::MIME, mplot, w, h) function _inspectdr_show(io::IO, mime::MIME, mplot, w, h)
InspectDR._show(io, mime, mplot, Float64(w), Float64(h)) InspectDR._show(io, mime, mplot, Float64(w), Float64(h))

View File

@ -504,7 +504,7 @@ function _update_plot_object(plt::Plot{PGFPlotsBackend})
bb = bbox(sp) bb = bbox(sp)
push!(style, """ push!(style, """
xshift = $(left(bb).value)mm, xshift = $(left(bb).value)mm,
yshift = $(round((total_height - (bottom(bb))).value,2))mm, yshift = $(round((total_height - (bottom(bb))).value, digits=2))mm,
axis background/.style={fill=$(pgf_color(sp[:background_color_inside])[1])} axis background/.style={fill=$(pgf_color(sp[:background_color_inside])[1])}
""") """)
kw[:width] = "$(width(bb).value)mm" kw[:width] = "$(width(bb).value)mm"
@ -607,7 +607,7 @@ function _show(io::IO, mime::MIME"application/pdf", plt::Plot{PGFPlotsBackend})
PGFPlots.save(PGFPlots.PDF(fn), pgfplt) PGFPlots.save(PGFPlots.PDF(fn), pgfplt)
# read it into io # read it into io
write(io, readstring(open(fn))) write(io, read(open(fn), String))
# cleanup # cleanup
PGFPlots.cleanup(plt.o) PGFPlots.cleanup(plt.o)
@ -616,7 +616,7 @@ end
function _show(io::IO, mime::MIME"application/x-tex", plt::Plot{PGFPlotsBackend}) function _show(io::IO, mime::MIME"application/x-tex", plt::Plot{PGFPlotsBackend})
fn = tempname()*".tex" fn = tempname()*".tex"
PGFPlots.save(fn, backend_object(plt), include_preamble=false) PGFPlots.save(fn, backend_object(plt), include_preamble=false)
write(io, readstring(open(fn))) write(io, read(open(fn), String))
end end
function _display(plt::Plot{PGFPlotsBackend}) function _display(plt::Plot{PGFPlotsBackend})

View File

@ -450,7 +450,7 @@ function plotly_colorscale(c::AbstractVector{<:RGBA}, α)
if length(c) == 1 if length(c) == 1
return [[0.0, rgba_string(plot_color(c[1], α))], [1.0, rgba_string(plot_color(c[1], α))]] return [[0.0, rgba_string(plot_color(c[1], α))], [1.0, rgba_string(plot_color(c[1], α))]]
else else
vals = linspace(0.0, 1.0, length(c)) vals = range(0.0, stop=1.0, length=length(c))
return [[vals[i], rgba_string(plot_color(c[i], α))] for i in eachindex(c)] return [[vals[i], rgba_string(plot_color(c[i], α))] for i in eachindex(c)]
end end
end end

View File

@ -82,21 +82,21 @@ function _initialize_backend(::PyPlotBackend)
append!(Base.Multimedia.displays, otherdisplays) append!(Base.Multimedia.displays, otherdisplays)
export PyPlot export PyPlot
const pycolors = PyPlot.pyimport("matplotlib.colors") pycolors = PyPlot.pyimport("matplotlib.colors")
const pypath = PyPlot.pyimport("matplotlib.path") pypath = PyPlot.pyimport("matplotlib.path")
const mplot3d = PyPlot.pyimport("mpl_toolkits.mplot3d") mplot3d = PyPlot.pyimport("mpl_toolkits.mplot3d")
const pypatches = PyPlot.pyimport("matplotlib.patches") pypatches = PyPlot.pyimport("matplotlib.patches")
const pyfont = PyPlot.pyimport("matplotlib.font_manager") pyfont = PyPlot.pyimport("matplotlib.font_manager")
const pyticker = PyPlot.pyimport("matplotlib.ticker") pyticker = PyPlot.pyimport("matplotlib.ticker")
const pycmap = PyPlot.pyimport("matplotlib.cm") pycmap = PyPlot.pyimport("matplotlib.cm")
const pynp = PyPlot.pyimport("numpy") pynp = PyPlot.pyimport("numpy")
pynp["seterr"](invalid="ignore") pynp["seterr"](invalid="ignore")
const pytransforms = PyPlot.pyimport("matplotlib.transforms") pytransforms = PyPlot.pyimport("matplotlib.transforms")
const pycollections = PyPlot.pyimport("matplotlib.collections") pycollections = PyPlot.pyimport("matplotlib.collections")
const pyart3d = PyPlot.art3D pyart3d = PyPlot.art3D
# "support" matplotlib v1.5 # "support" matplotlib v1.5
const set_facecolor_sym = if PyPlot.version < v"2" set_facecolor_sym = if PyPlot.version < v"2"
warn("You are using Matplotlib $(PyPlot.version), which is no longer officialy supported by the Plots community. To ensure smooth Plots.jl integration update your Matplotlib library to a version >= 2.0.0") warn("You are using Matplotlib $(PyPlot.version), which is no longer officialy supported by the Plots community. To ensure smooth Plots.jl integration update your Matplotlib library to a version >= 2.0.0")
:set_axis_bgcolor :set_axis_bgcolor
else else

View File

@ -32,7 +32,7 @@ function open_browser_window(filename::AbstractString)
@static if is_windows() @static if is_windows()
return run(`$(ENV["COMSPEC"]) /c start "" "$(filename)"`) return run(`$(ENV["COMSPEC"]) /c start "" "$(filename)"`)
end end
warn("Unknown OS... cannot open browser window.") @warn("Unknown OS... cannot open browser window.")
end end
function write_temp_html(plt::AbstractPlot) function write_temp_html(plt::AbstractPlot)

View File

@ -58,7 +58,7 @@ end
"get an array of tuples of points on a circle with radius `r`" "get an array of tuples of points on a circle with radius `r`"
function partialcircle(start_θ, end_θ, n = 20, r=1) function partialcircle(start_θ, end_θ, n = 20, r=1)
Tuple{Float64,Float64}[(r*cos(u),r*sin(u)) for u in linspace(start_θ, end_θ, n)] Tuple{Float64,Float64}[(r*cos(u),r*sin(u)) for u in range(start_θ, stop=end_θ, length=n)]
end end
"interleave 2 vectors into each other (like a zipper's teeth)" "interleave 2 vectors into each other (like a zipper's teeth)"
@ -68,7 +68,8 @@ function weave(x,y; ordering = Vector[x,y])
while !done while !done
for o in ordering for o in ordering
try try
push!(ret, shift!(o)) push!(ret, popfirst!(o))
catch
end end
end end
done = isempty(x) && isempty(y) done = isempty(x) && isempty(y)
@ -388,6 +389,7 @@ function stroke(args...; alpha = nothing)
elseif T <: Symbol || T <: AbstractString elseif T <: Symbol || T <: AbstractString
try try
color = parse(Colorant, string(arg)) color = parse(Colorant, string(arg))
catch
end end
elseif allAlphas(arg) elseif allAlphas(arg)
alpha = arg alpha = arg
@ -420,6 +422,7 @@ function brush(args...; alpha = nothing)
elseif T <: Symbol || T <: AbstractString elseif T <: Symbol || T <: AbstractString
try try
color = parse(Colorant, string(arg)) color = parse(Colorant, string(arg))
catch
end end
elseif allAlphas(arg) elseif allAlphas(arg)
alpha = arg alpha = arg
@ -468,7 +471,7 @@ function series_annotations(strs::AbstractVector, args...)
SeriesAnnotations(strs, fnt, shp, scalefactor) SeriesAnnotations(strs, fnt, shp, scalefactor)
end end
series_annotations(anns::SeriesAnnotations) = anns series_annotations(anns::SeriesAnnotations) = anns
series_annotations(::Void) = nothing series_annotations(::Nothing) = nothing
function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels) function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
anns = series[:series_annotations] anns = series[:series_annotations]
@ -531,7 +534,7 @@ function Base.next(ea::EachAnn, i)
((_cycle(ea.x,i), _cycle(ea.y,i), str, fnt), i+1) ((_cycle(ea.x,i), _cycle(ea.y,i), str, fnt), i+1)
end end
annotations(::Void) = [] annotations(::Nothing) = []
annotations(anns::AVec) = anns annotations(anns::AVec) = anns
annotations(anns) = Any[anns] annotations(anns) = Any[anns]
annotations(sa::SeriesAnnotations) = sa annotations(sa::SeriesAnnotations) = sa
@ -747,7 +750,7 @@ end
@deprecate curve_points coords @deprecate curve_points coords
coords(curve::BezierCurve, n::Integer = 30; range = [0,1]) = map(curve, linspace(range..., n)) coords(curve::BezierCurve, n::Integer = 30; range = [0,1]) = map(curve, range(range..., stop=n, length=50))
# build a BezierCurve which leaves point p vertically upwards and arrives point q vertically upwards. # build a BezierCurve which leaves point p vertically upwards and arrives point q vertically upwards.
# may create a loop if necessary. Assumes the view is [0,1] # may create a loop if necessary. Assumes the view is [0,1]

View File

@ -72,7 +72,7 @@ is_subplot_supported(::BokehBackend) = false
function _initialize_backend(::BokehBackend; kw...) function _initialize_backend(::BokehBackend; kw...)
@eval begin @eval begin
warn("Bokeh is no longer supported... many features will likely be broken.") @warn("Bokeh is no longer supported... many features will likely be broken.")
import Bokeh import Bokeh
export Bokeh export Bokeh
end end
@ -196,7 +196,7 @@ end
function Base.show(io::IO, ::MIME"image/png", plt::AbstractPlot{BokehBackend}) function Base.show(io::IO, ::MIME"image/png", plt::AbstractPlot{BokehBackend})
# TODO: write a png to io # TODO: write a png to io
warn("mime png not implemented") @warn("mime png not implemented")
end end
function Base.display(::PlotsDisplay, plt::Plot{BokehBackend}) function Base.display(::PlotsDisplay, plt::Plot{BokehBackend})

View File

@ -244,7 +244,7 @@ function addToGadflyLegend(plt::Plot, d::KW)
# add the legend if needed # add the legend if needed
if all(g -> !isa(g, Gadfly.Guide.ManualColorKey), gplt.guides) if all(g -> !isa(g, Gadfly.Guide.ManualColorKey), gplt.guides)
unshift!(gplt.guides, Gadfly.Guide.manual_color_key("", AbstractString[], Color[])) pushfirst!(gplt.guides, Gadfly.Guide.manual_color_key("", AbstractString[], Color[]))
end end
# now add the series to the legend # now add the series to the legend

View File

@ -31,7 +31,7 @@ is_subplot_supported(::QwtBackend) = true
function _initialize_backend(::QwtBackend; kw...) function _initialize_backend(::QwtBackend; kw...)
@eval begin @eval begin
warn("Qwt is no longer supported... many features will likely be broken.") @warn("Qwt is no longer supported... many features will likely be broken.")
import Qwt import Qwt
export Qwt export Qwt
end end
@ -142,7 +142,7 @@ function updateLimsAndTicks(plt::Plot{QwtBackend}, d::KW, isx::Bool)
w[:setAxisScale](axisid, lims...) w[:setAxisScale](axisid, lims...)
end end
if typeof(ticks) <: Range if typeof(ticks) <: AbstractRange
if isx if isx
plt.o.autoscale_x = false plt.o.autoscale_x = false
else else

View File

@ -34,7 +34,7 @@ is_subplot_supported(::WinstonBackend) = false
function _initialize_backend(::WinstonBackend; kw...) function _initialize_backend(::WinstonBackend; kw...)
@eval begin @eval begin
# ENV["WINSTON_OUTPUT"] = "gtk" # ENV["WINSTON_OUTPUT"] = "gtk"
warn("Winston is no longer supported... many features will likely be broken.") @warn("Winston is no longer supported... many features will likely be broken.")
import Winston, Gtk import Winston, Gtk
export Winston, Gtk export Winston, Gtk
end end

View File

@ -19,7 +19,7 @@
# work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. # work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
function sample_evenly(v::AVec, n::Integer = length(v)) function sample_evenly(v::AVec, n::Integer = length(v))
idx = Int[round(Int, x) for x in linspace(1, length(v), n)] idx = Int[round(Int, x) for x in range(1, stop=length(v), length=n)]
v[idx] v[idx]
end end

View File

@ -13,15 +13,15 @@ function cgrad(arg, values = nothing; alpha = nothing, scale = :identity)
values = if values != nothing values = if values != nothing
values values
elseif scale in (:log, :log10) elseif scale in (:log, :log10)
log10(linspace(1,10,30)) log10(range(1, stop=10, length=30))
elseif scale == :log2 elseif scale == :log2
log2(linspace(1,2,30)) log2(range(1, stop=2, length=30))
elseif scale == :ln elseif scale == :ln
log(linspace(1,pi,30)) log(range(1, stop=pi, length=30))
elseif scale in (:exp, :exp10) elseif scale in (:exp, :exp10)
(exp10(linspace(0,1,30)) - 1) / 9 (exp10(range(0, stop=1, length=30)) - 1) / 9
else else
linspace(0, 1, length(colors)) range(0, stop=1, length=length(colors))
end end
ColorGradient(colors, values) ColorGradient(colors, values)
end end
@ -51,7 +51,7 @@ convertColor(c::Symbol) = parse(Colorant, string(c))
convertColor(c::Colorant) = c convertColor(c::Colorant) = c
convertColor(cvec::AbstractVector) = map(convertColor, cvec) convertColor(cvec::AbstractVector) = map(convertColor, cvec)
convertColor(c::ColorScheme) = c convertColor(c::ColorScheme) = c
convertColor(v::Void) = RGBA(0,0,0,0) convertColor(v::Nothing) = RGBA(0,0,0,0)
convertColor(b::Bool) = b ? RGBA(0,0,0,1) : RGBA(0,0,0,0) convertColor(b::Bool) = b ? RGBA(0,0,0,1) : RGBA(0,0,0,0)
function convertColor(c, α::Real) function convertColor(c, α::Real)
@ -59,7 +59,7 @@ function convertColor(c, α::Real)
RGBA(RGB(getColor(c)), α) RGBA(RGB(getColor(c)), α)
end end
convertColor(cs::AVec, α::Real) = map(c -> convertColor(c, α), cs) convertColor(cs::AVec, α::Real) = map(c -> convertColor(c, α), cs)
convertColor(c, α::Void) = convertColor(c) convertColor(c, α::Nothing) = convertColor(c)
# backup... try to convert # backup... try to convert
getColor(c) = convertColor(c) getColor(c) = convertColor(c)
@ -113,7 +113,7 @@ struct ColorGradient <: ColorScheme
colors::Vector colors::Vector
values::Vector values::Vector
function ColorGradient(cs::AVec, vals::AVec{S} = linspace(0, 1, length(cs)); alpha = nothing) where S<:Real function ColorGradient(cs::AVec, vals::AVec{S} = range(0, stop=1, length=length(cs)); alpha = nothing) where S<:Real
if length(cs) == length(vals) if length(cs) == length(vals)
return new(convertColor(cs,alpha), collect(vals)) return new(convertColor(cs,alpha), collect(vals))
end end
@ -124,9 +124,9 @@ struct ColorGradient <: ColorScheme
# new(convertColor(cs,alpha), vs) # new(convertColor(cs,alpha), vs)
# interpolate the colors for each value # interpolate the colors for each value
vals = merge(linspace(0, 1, length(cs)), vals) vals = merge(range(0, stop=1, length=length(cs)), vals)
grad = ColorGradient(cs) grad = ColorGradient(cs)
cs = [getColorZ(grad, z) for z in linspace(0, 1, length(vals))] cs = [getColorZ(grad, z) for z in range(0, stop=1, length=length(vals))]
new(convertColor(cs, alpha), vals) new(convertColor(cs, alpha), vals)
end end
end end
@ -142,7 +142,7 @@ function ColorGradient(s::Symbol, vals::AVec{T} = 0:0; kw...) where T<:Real
haskey(_gradients, s) || error("Invalid gradient symbol. Choose from: ", sort(collect(keys(_gradients)))) haskey(_gradients, s) || error("Invalid gradient symbol. Choose from: ", sort(collect(keys(_gradients))))
cs = _gradients[s] cs = _gradients[s]
if vals == 0:0 if vals == 0:0
vals = linspace(0, 1, length(cs)) vals = range(0, stop=1, length=length(cs))
end end
ColorGradient(cs, vals; kw...) ColorGradient(cs, vals; kw...)
end end
@ -247,7 +247,7 @@ ColorWrapper(s::Symbol; alpha = nothing) = ColorWrapper(convertColor(parse(Color
getColor(scheme::ColorWrapper, idx::Int) = scheme.c getColor(scheme::ColorWrapper, idx::Int) = scheme.c
getColorZ(scheme::ColorWrapper, z::Real) = scheme.c getColorZ(scheme::ColorWrapper, z::Real) = scheme.c
convertColor(c::ColorWrapper, α::Void) = c.c convertColor(c::ColorWrapper, α::Nothing) = c.c
# -------------------------------------------------------------- # --------------------------------------------------------------
@ -332,7 +332,7 @@ function generate_colorgradient(bgcolor = colorant"white";
seed_colors, seed_colors,
lchoices=Float64[lightness], lchoices=Float64[lightness],
cchoices=Float64[chroma], cchoices=Float64[chroma],
hchoices=linspace(0, 340, 20) hchoices=range(0, stop=340, length=20)
)[2:end] )[2:end]
gradient_from_list(colors) gradient_from_list(colors)
end end

View File

@ -10,7 +10,7 @@ const FuncOrFuncs = Union{Function, AVec{Function}}
all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :contourf, :heatmap, :surface, :wireframe, :contour3d, :image), get(d, :seriestype, :none)) all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :contourf, :heatmap, :surface, :wireframe, :contour3d, :image), get(d, :seriestype, :none))
# missing # missing
convertToAnyVector(v::Void, d::KW) = Any[nothing], nothing convertToAnyVector(v::Nothing, d::KW) = Any[nothing], nothing
# fixed number of blank series # fixed number of blank series
convertToAnyVector(n::Integer, d::KW) = Any[zeros(0) for i in 1:n], nothing convertToAnyVector(n::Integer, d::KW) = Any[zeros(0) for i in 1:n], nothing
@ -65,19 +65,19 @@ end
# TODO: can we avoid the copy here? one error that crops up is that mapping functions over the same array # TODO: can we avoid the copy here? one error that crops up is that mapping functions over the same array
# result in that array being shared. push!, etc will add too many items to that array # result in that array being shared. push!, etc will add too many items to that array
compute_x(x::Void, y::Void, z) = 1:size(z,1) compute_x(x::Nothing, y::Nothing, z) = 1:size(z,1)
compute_x(x::Void, y, z) = 1:size(y,1) compute_x(x::Nothing, y, z) = 1:size(y,1)
compute_x(x::Function, y, z) = map(x, y) compute_x(x::Function, y, z) = map(x, y)
compute_x(x, y, z) = copy(x) compute_x(x, y, z) = copy(x)
# compute_y(x::Void, y::Function, z) = error() # compute_y(x::Void, y::Function, z) = error()
compute_y(x::Void, y::Void, z) = 1:size(z,2) compute_y(x::Nothing, y::Nothing, z) = 1:size(z,2)
compute_y(x, y::Function, z) = map(y, x) compute_y(x, y::Function, z) = map(y, x)
compute_y(x, y, z) = copy(y) compute_y(x, y, z) = copy(y)
compute_z(x, y, z::Function) = map(z, x, y) compute_z(x, y, z::Function) = map(z, x, y)
compute_z(x, y, z::AbstractMatrix) = Surface(z) compute_z(x, y, z::AbstractMatrix) = Surface(z)
compute_z(x, y, z::Void) = nothing compute_z(x, y, z::Nothing) = nothing
compute_z(x, y, z) = copy(z) compute_z(x, y, z) = copy(z)
nobigs(v::AVec{BigFloat}) = map(Float64, v) nobigs(v::AVec{BigFloat}) = map(Float64, v)
@ -92,8 +92,8 @@ nobigs(v) = v
end end
# not allowed # not allowed
compute_xyz(x::Void, y::FuncOrFuncs, z) = error("If you want to plot the function `$y`, you need to define the x values!") compute_xyz(x::Nothing, y::FuncOrFuncs, z) = error("If you want to plot the function `$y`, you need to define the x values!")
compute_xyz(x::Void, y::Void, z::FuncOrFuncs) = error("If you want to plot the function `$z`, you need to define x and y values!") compute_xyz(x::Nothing, y::Nothing, z::FuncOrFuncs) = error("If you want to plot the function `$z`, you need to define x and y values!")
compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") compute_xyz(x::Nothing, y::Nothing, z::Nothing) = error("x/y/z are all nothing!")
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -29,7 +29,7 @@ animation.
[:(begin [:(begin
p = plot([sin,cos], zeros(0), leg=false) p = plot([sin,cos], zeros(0), leg=false)
anim = Animation() anim = Animation()
for x in linspace(0, 10π, 100) for x in range(0, stop=10π, length=100)
push!(p, x, Float64[sin(x), cos(x)]) push!(p, x, Float64[sin(x), cos(x)])
frame(anim) frame(anim)
end end
@ -156,7 +156,7 @@ PlotExample("Marker types",
markers = filter(m -> m in Plots.supported_markers(), Plots._shape_keys) markers = filter(m -> m in Plots.supported_markers(), Plots._shape_keys)
markers = reshape(markers, 1, length(markers)) markers = reshape(markers, 1, length(markers))
n = length(markers) n = length(markers)
x = linspace(0,10,n+2)[2:end-1] x = range(0, stop=10, length=n+2)[2:end-1]
y = repmat(reshape(reverse(x),1,:), n, 1) y = repmat(reshape(reverse(x),1,:), n, 1)
scatter(x, y, m=(8,:auto), lab=map(string,markers), bg=:linen, xlim=(0,10), ylim=(0,10)) scatter(x, y, m=(8,:auto), lab=map(string,markers), bg=:linen, xlim=(0,10), ylim=(0,10))
end)] end)]
@ -238,7 +238,7 @@ y = rand(10)
plot(y, annotations = (3,y[3],text("this is #3",:left)), leg=false) plot(y, annotations = (3,y[3],text("this is #3",:left)), leg=false)
annotate!([(5, y[5], text("this is #5",16,:red,:center)), annotate!([(5, y[5], text("this is #5",16,:red,:center)),
(10, y[10], text("this is #10",:right,20,"courier"))]) (10, y[10], text("this is #10",:right,20,"courier"))])
scatter!(linspace(2,8,6), rand(6), marker=(50,0.2,:orange), scatter!(range(2, stop=8, length=6), rand(6), marker=(50,0.2,:orange),
series_annotations = ["series","annotations","map","to","series", series_annotations = ["series","annotations","map","to","series",
text("data",:green)]) text("data",:green)])
end)] end)]
@ -291,7 +291,7 @@ PlotExample("3D",
"", "",
[:(begin [:(begin
n = 100 n = 100
ts = linspace(0,8π,n) ts = range(0, stop=8π, length=n)
x = ts .* map(cos,ts) x = ts .* map(cos,ts)
y = 0.1ts .* map(sin,ts) y = 0.1ts .* map(sin,ts)
z = 1:n z = 1:n
@ -323,7 +323,7 @@ PlotExample("Groups and Subplots",
PlotExample("Polar Plots", PlotExample("Polar Plots",
"", "",
[:(begin [:(begin
Θ = linspace(0,1.5π,100) Θ = range(0, stop=1.5π, length=100)
r = abs.(0.1randn(100)+sin.(3Θ)) r = abs.(0.1randn(100)+sin.(3Θ))
plot(Θ, r, proj=:polar, m=2) plot(Θ, r, proj=:polar, m=2)
end)] end)]
@ -368,7 +368,7 @@ PlotExample("Animation with subplots",
plot(log,1,xlims=(1,10π),ylims=(0,5),leg=false),layout=l) plot(log,1,xlims=(1,10π),ylims=(0,5),leg=false),layout=l)
anim = Animation() anim = Animation()
for x = linspace(1,10π,100) for x = range(1, stop=10π, length=100)
plot(push!(p,x,Float64[sin(x),cos(x),atan(x),cos(x),log(x)])) plot(push!(p,x,Float64[sin(x),cos(x),atan(x),cos(x),log(x)]))
frame(anim) frame(anim)
end end
@ -422,7 +422,7 @@ You can use the `line_z` and `marker_z` properties to associate a color with
each line segment or marker in the plot. each line segment or marker in the plot.
""", """,
[:(begin [:(begin
t = linspace(0, 1, 100) t = range(0, stop=1, length=100)
θ = 6π .* t θ = 6π .* t
x = t .* cos.(θ) x = t .* cos.(θ)
y = t .* sin.(θ) y = t .* sin.(θ)

View File

@ -566,7 +566,7 @@ function build_layout(layout::GridLayout, numsp::Integer, plts::AVec{Plot})
for r=1:nr, c=1:nc for r=1:nr, c=1:nc
l = layout[r,c] l = layout[r,c]
if isa(l, EmptyLayout) && !get(l.attr, :blank, false) if isa(l, EmptyLayout) && !get(l.attr, :blank, false)
plt = shift!(plts) # grab the first plot out of the list plt = popfirst!(plts) # grab the first plot out of the list
layout[r,c] = plt.layout layout[r,c] = plt.layout
append!(subplots, plt.subplots) append!(subplots, plt.subplots)
merge!(spmap, plt.spmap) merge!(spmap, plt.spmap)

View File

@ -186,11 +186,11 @@ end
# delegate mimewritable (showable on julia 0.7) to _show instead # delegate mimewritable (showable on julia 0.7) to _show instead
function Base.mimewritable(m::M, plt::P) where {M<:MIME, P<:Plot} function Base.mimewritable(m::M, plt::P) where {M<:MIME, P<:Plot}
return method_exists(_show, Tuple{IO, M, P}) return hasmethod(_show, Tuple{IO, M, P})
end end
function _display(plt::Plot) function _display(plt::Plot)
warn("_display is not defined for this backend.") @warn("_display is not defined for this backend.")
end end
# for writing to io streams... first prepare, then callback # for writing to io streams... first prepare, then callback
@ -230,7 +230,7 @@ if is_installed("FileIO")
FileIO.save(pngfn, s) FileIO.save(pngfn, s)
# now write from the file # now write from the file
write(io, readstring(open(pngfn))) write(io, read(open(pngfn), String))
end end
end end

View File

@ -70,7 +70,7 @@ function _process_userrecipes(plt::Plot, d::KW, args)
# grab the first in line to be processed and either add it to the kw_list or # grab the first in line to be processed and either add it to the kw_list or
# pass it through apply_recipe to generate a list of RecipeData objects (data + attributes) # pass it through apply_recipe to generate a list of RecipeData objects (data + attributes)
# for further processing. # for further processing.
next_series = shift!(still_to_process) next_series = popfirst!(still_to_process)
# recipedata should be of type RecipeData. if it's not then the inputs must not have been fully processed by recipes # recipedata should be of type RecipeData. if it's not then the inputs must not have been fully processed by recipes
if !(typeof(next_series) <: RecipeData) if !(typeof(next_series) <: RecipeData)
error("Inputs couldn't be processed... expected RecipeData but got: $next_series") error("Inputs couldn't be processed... expected RecipeData but got: $next_series")
@ -329,7 +329,7 @@ function _override_seriestype_check(d::KW, st::Symbol)
# do we want to override the series type? # do we want to override the series type?
if !is3d(st) && !(st in (:contour,:contour3d)) if !is3d(st) && !(st in (:contour,:contour3d))
z = d[:z] z = d[:z]
if !isa(z, Void) && (size(d[:x]) == size(d[:y]) == size(z)) if !isa(z, Nothing) && (size(d[:x]) == size(d[:y]) == size(z))
st = (st == :scatter ? :scatter3d : :path3d) st = (st == :scatter ? :scatter3d : :path3d)
d[:seriestype] = st d[:seriestype] = st
end end

View File

@ -169,7 +169,7 @@ function _plot!(plt::Plot, d::KW, args::Tuple)
if !isempty(args) && !isdefined(Main, :StatPlots) && if !isempty(args) && !isdefined(Main, :StatPlots) &&
first(split(string(typeof(args[1])), ".")) == "DataFrames" first(split(string(typeof(args[1])), ".")) == "DataFrames"
warn("You're trying to plot a DataFrame, but this functionality is provided by StatPlots") @warn("You're trying to plot a DataFrame, but this functionality is provided by StatPlots")
end end
# -------------------------------- # --------------------------------
@ -193,7 +193,7 @@ function _plot!(plt::Plot, d::KW, args::Tuple)
still_to_process = kw_list still_to_process = kw_list
kw_list = KW[] kw_list = KW[]
while !isempty(still_to_process) while !isempty(still_to_process)
next_kw = shift!(still_to_process) next_kw = popfirst!(still_to_process)
_process_plotrecipe(plt, next_kw, kw_list, still_to_process) _process_plotrecipe(plt, next_kw, kw_list, still_to_process)
end end

View File

@ -620,10 +620,10 @@ _hist_edge(vs::NTuple{N,AbstractVector}, dim::Integer, binning::Symbol) where {N
_hist_edge(vs::NTuple{N,AbstractVector}, dim::Integer, binning::AbstractVector) where {N} = binning _hist_edge(vs::NTuple{N,AbstractVector}, dim::Integer, binning::AbstractVector) where {N} = binning
_hist_edges(vs::NTuple{N,AbstractVector}, binning::NTuple{N}) where {N} = _hist_edges(vs::NTuple{N,AbstractVector}, binning::NTuple{N}) where {N} =
map(dim -> _hist_edge(vs, dim, binning[dim]), (1:N...)) map(dim -> _hist_edge(vs, dim, binning[dim]), (1:N...,))
_hist_edges(vs::NTuple{N,AbstractVector}, binning::Union{Integer, Symbol, AbstractVector}) where {N} = _hist_edges(vs::NTuple{N,AbstractVector}, binning::Union{Integer, Symbol, AbstractVector}) where {N} =
map(dim -> _hist_edge(vs, dim, binning), (1:N...)) map(dim -> _hist_edge(vs, dim, binning), (1:N...,))
_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
@ -792,7 +792,7 @@ end
function error_coords(xorig, yorig, ebar) function error_coords(xorig, yorig, ebar)
# init empty x/y, and zip errors if passed Tuple{Vector,Vector} # init empty x/y, and zip errors if passed Tuple{Vector,Vector}
x, y = Array{float_extended_type(xorig)}(0), Array{Float64}(0) x, y = Array{float_extended_type(xorig)}(undef, 0), Array{Float64}(undef, 0)
# for each point, create a line segment from the bottom to the top of the errorbar # for each point, create a line segment from the bottom to the top of the errorbar
for i = 1:max(length(xorig), length(yorig)) for i = 1:max(length(xorig), length(yorig))
xi = _cycle(xorig, i) xi = _cycle(xorig, i)

View File

@ -14,7 +14,7 @@ all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :contourf, :heatmap, :surfac
convertToAnyVector(x, d::KW) = error("No user recipe defined for $(typeof(x))") convertToAnyVector(x, d::KW) = error("No user recipe defined for $(typeof(x))")
# missing # missing
convertToAnyVector(v::Void, d::KW) = Any[nothing], nothing convertToAnyVector(v::Nothing, d::KW) = Any[nothing], nothing
# fixed number of blank series # fixed number of blank series
convertToAnyVector(n::Integer, d::KW) = Any[zeros(0) for i in 1:n], nothing convertToAnyVector(n::Integer, d::KW) = Any[zeros(0) for i in 1:n], nothing
@ -46,7 +46,7 @@ convertToAnyVector(v::Volume, d::KW) = Any[v], nothing
# convertToAnyVector(v::AVec{OHLC}, d::KW) = Any[v], nothing # convertToAnyVector(v::AVec{OHLC}, d::KW) = Any[v], nothing
# # dates # # dates
convertToAnyVector{D<:Union{Date,DateTime}}(dts::AVec{D}, d::KW) = Any[dts], nothing convertToAnyVector(dts::AVec{D}, d::KW) where {D<:Union{Date,DateTime}} = Any[dts], nothing
# list of things (maybe other vectors, functions, or something else) # list of things (maybe other vectors, functions, or something else)
function convertToAnyVector(v::AVec, d::KW) function convertToAnyVector(v::AVec, d::KW)
@ -72,19 +72,19 @@ end
# TODO: can we avoid the copy here? one error that crops up is that mapping functions over the same array # TODO: can we avoid the copy here? one error that crops up is that mapping functions over the same array
# result in that array being shared. push!, etc will add too many items to that array # result in that array being shared. push!, etc will add too many items to that array
compute_x(x::Void, y::Void, z) = 1:size(z,1) compute_x(x::Nothing, y::Nothing, z) = 1:size(z,1)
compute_x(x::Void, y, z) = 1:size(y,1) compute_x(x::Nothing, y, z) = 1:size(y,1)
compute_x(x::Function, y, z) = map(x, y) compute_x(x::Function, y, z) = map(x, y)
compute_x(x, y, z) = copy(x) compute_x(x, y, z) = copy(x)
# compute_y(x::Void, y::Function, z) = error() # compute_y(x::Void, y::Function, z) = error()
compute_y(x::Void, y::Void, z) = 1:size(z,2) compute_y(x::Nothing, y::Nothing, z) = 1:size(z,2)
compute_y(x, y::Function, z) = map(y, x) compute_y(x, y::Function, z) = map(y, x)
compute_y(x, y, z) = copy(y) compute_y(x, y, z) = copy(y)
compute_z(x, y, z::Function) = map(z, x, y) compute_z(x, y, z::Function) = map(z, x, y)
compute_z(x, y, z::AbstractMatrix) = Surface(z) compute_z(x, y, z::AbstractMatrix) = Surface(z)
compute_z(x, y, z::Void) = nothing compute_z(x, y, z::Nothing) = nothing
compute_z(x, y, z) = copy(z) compute_z(x, y, z) = copy(z)
nobigs(v::AVec{BigFloat}) = map(Float64, v) nobigs(v::AVec{BigFloat}) = map(Float64, v)
@ -99,9 +99,9 @@ nobigs(v) = v
end end
# not allowed # not allowed
compute_xyz(x::Void, y::FuncOrFuncs{F}, z) where {F<:Function} = error("If you want to plot the function `$y`, you need to define the x values!") compute_xyz(x::Nothing, y::FuncOrFuncs{F}, z) where {F<:Function} = error("If you want to plot the function `$y`, you need to define the x values!")
compute_xyz(x::Void, y::Void, z::FuncOrFuncs{F}) where {F<:Function} = error("If you want to plot the function `$z`, you need to define x and y values!") compute_xyz(x::Nothing, y::Nothing, z::FuncOrFuncs{F}) where {F<:Function} = error("If you want to plot the function `$z`, you need to define x and y values!")
compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") compute_xyz(x::Nothing, y::Nothing, z::Nothing) = error("x/y/z are all nothing!")
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -6,7 +6,7 @@ const AVec = AbstractVector
const AMat = AbstractMatrix const AMat = AbstractMatrix
const KW = Dict{Symbol,Any} const KW = Dict{Symbol,Any}
struct PlotsDisplay <: Display end struct PlotsDisplay <: AbstractDisplay end
# ----------------------------------------------------------- # -----------------------------------------------------------

View File

@ -4,7 +4,7 @@ calcMidpoints(edges::AbstractVector) = Float64[0.5 * (edges[i] + edges[i+1]) for
"Make histogram-like bins of data" "Make histogram-like bins of data"
function binData(data, nbins) function binData(data, nbins)
lo, hi = ignorenan_extrema(data) lo, hi = ignorenan_extrema(data)
edges = collect(linspace(lo, hi, nbins+1)) edges = collect(range(lo, stop=hi, length=nbins+1))
midpoints = calcMidpoints(edges) midpoints = calcMidpoints(edges)
buckets = Int[max(2, min(searchsortedfirst(edges, x), length(edges)))-1 for x in data] buckets = Int[max(2, min(searchsortedfirst(edges, x), length(edges)))-1 for x in data]
counts = zeros(Int, length(midpoints)) counts = zeros(Int, length(midpoints))
@ -119,7 +119,7 @@ function replace_image_with_heatmap(z::Array{T}) where T<:Colorant
n, m = size(z) n, m = size(z)
# idx = 0 # idx = 0
colors = ColorGradient(vec(z)) colors = ColorGradient(vec(z))
newz = reshape(linspace(0, 1, n*m), n, m) newz = reshape(range(0, stop=1, length=n*m), n, m)
newz, colors newz, colors
# newz = zeros(n, m) # newz = zeros(n, m)
# for i=1:n, j=1:m # for i=1:n, j=1:m
@ -259,7 +259,7 @@ float_extended_type(x::AbstractArray{T}) where {T<:Real} = Float64
nop() = nothing nop() = nothing
notimpl() = error("This has not been implemented yet") notimpl() = error("This has not been implemented yet")
isnothing(x::Void) = true isnothing(x::Nothing) = true
isnothing(x) = false isnothing(x) = false
_cycle(wrapper::InputWrapper, idx::Int) = wrapper.obj _cycle(wrapper::InputWrapper, idx::Int) = wrapper.obj
@ -307,6 +307,7 @@ function _expand_limits(lims, x)
lims[2] = NaNMath.max(lims[2], e2) lims[2] = NaNMath.max(lims[2], e2)
# catch err # catch err
# warn(err) # warn(err)
catch
end end
nothing nothing
end end
@ -450,8 +451,8 @@ limsType(lims) = :invalid
# axis_Symbol(letter, postfix) = Symbol(letter * postfix) # axis_Symbol(letter, postfix) = Symbol(letter * postfix)
# axis_symbols(letter, postfix...) = map(s -> axis_Symbol(letter, s), postfix) # axis_symbols(letter, postfix...) = map(s -> axis_Symbol(letter, s), postfix)
Base.convert(::Type{Vector{T}}, rng::Range{T}) where {T<:Real} = T[x for x in rng] Base.convert(::Type{Vector{T}}, rng::AbstractRange{T}) where {T<:Real} = T[x for x in rng]
Base.convert(::Type{Vector{T}}, rng::Range{S}) where {T<:Real,S<:Real} = T[x for x in rng] Base.convert(::Type{Vector{T}}, rng::AbstractRange{S}) where {T<:Real,S<:Real} = T[x for x in rng]
Base.merge(a::AbstractVector, b::AbstractVector) = sort(unique(vcat(a,b))) Base.merge(a::AbstractVector, b::AbstractVector) = sort(unique(vcat(a,b)))
@ -846,8 +847,8 @@ end
extendSeriesByOne(v::UnitRange{Int}, n::Int = 1) = isempty(v) ? (1:n) : (minimum(v):maximum(v)+n) extendSeriesByOne(v::UnitRange{Int}, n::Int = 1) = isempty(v) ? (1:n) : (minimum(v):maximum(v)+n)
extendSeriesByOne(v::AVec, n::Integer = 1) = isempty(v) ? (1:n) : vcat(v, (1:n) + ignorenan_maximum(v)) extendSeriesByOne(v::AVec, n::Integer = 1) = isempty(v) ? (1:n) : vcat(v, (1:n) + ignorenan_maximum(v))
extendSeriesData(v::Range{T}, z::Real) where {T} = extendSeriesData(float(collect(v)), z) extendSeriesData(v::AbstractRange{T}, z::Real) where {T} = extendSeriesData(float(collect(v)), z)
extendSeriesData(v::Range{T}, z::AVec) where {T} = extendSeriesData(float(collect(v)), z) extendSeriesData(v::AbstractRange{T}, z::AVec) where {T} = extendSeriesData(float(collect(v)), z)
extendSeriesData(v::AVec{T}, z::Real) where {T} = (push!(v, convert(T, z)); v) extendSeriesData(v::AVec{T}, z::Real) where {T} = (push!(v, convert(T, z)); v)
extendSeriesData(v::AVec{T}, z::AVec) where {T} = (append!(v, convert(Vector{T}, z)); v) extendSeriesData(v::AVec{T}, z::AVec) where {T} = (append!(v, convert(Vector{T}, z)); v)
@ -856,7 +857,7 @@ extendSeriesData(v::AVec{T}, z::AVec) where {T} = (append!(v, convert(Ve
# NOTE: backends should implement the following methods to get/set the x/y/z data objects # NOTE: backends should implement the following methods to get/set the x/y/z data objects
tovec(v::AbstractVector) = v tovec(v::AbstractVector) = v
tovec(v::Void) = zeros(0) tovec(v::Nothing) = zeros(0)
function getxy(plt::Plot, i::Integer) function getxy(plt::Plot, i::Integer)
d = plt.series_list[i].d d = plt.series_list[i].d