From bf0b22906be0d7fe81c5349c0bfe782ac2e422b2 Mon Sep 17 00:00:00 2001 From: Ederag Date: Sat, 12 May 2018 18:39:14 +0200 Subject: [PATCH 1/4] use nothing --- src/backends/hdf5.jl | 6 +++--- src/components.jl | 6 +++--- src/plot.jl | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backends/hdf5.jl b/src/backends/hdf5.jl index 2cbe7a768..d68bfef62 100644 --- a/src/backends/hdf5.jl +++ b/src/backends/hdf5.jl @@ -169,7 +169,7 @@ function _initialize_backend(::HDF5Backend) "AXIS" => Axis, "SURFACE" => Surface, "SUBPLOT" => Subplot, - "NULLABLE" => Nullable, + "NULLABLE" => Union{AbstractPlot, Nothing}, ) merge!(HDF5PLOT_MAP_STR2TELEM, telem2str) merge!(HDF5PLOT_MAP_TELEM2STR, Dict{Type, String}(v=>k for (k,v) in HDF5PLOT_MAP_STR2TELEM)) @@ -413,8 +413,8 @@ function _hdf5plot_gwrite(grp, k::String, v::Surface) _hdf5plot_gwrite(grp, "data2d", v.surf) _hdf5plot_writetype(grp, Surface) end -#TODO: "Properly" support Nullable using _hdf5plot_writetype? -function _hdf5plot_gwrite(grp, k::String, v::Nullable) +#TODO: "Properly" support Nothing using _hdf5plot_writetype? +function _hdf5plot_gwrite(grp, k::String, v::Union{AbstractPlot, Nothing}) if isnull(v) _hdf5plot_gwrite(grp, k, nothing) else diff --git a/src/components.jl b/src/components.jl index e7d3cc5d4..343582f3e 100644 --- a/src/components.jl +++ b/src/components.jl @@ -438,16 +438,16 @@ end mutable struct SeriesAnnotations strs::AbstractVector # the labels/names font::Font - baseshape::Nullable + baseshape::Union{Any, Nothing} scalefactor::Tuple end function series_annotations(strs::AbstractVector, args...) fnt = font() - shp = Union{Any, Nothing}() + shp = nothing scalefactor = (1,1) for arg in args if isa(arg, Shape) || (isa(arg, AbstractVector) && eltype(arg) == Shape) - shp = Nullable(arg) + shp = arg elseif isa(arg, Font) fnt = arg elseif isa(arg, Symbol) && haskey(_shapes, arg) diff --git a/src/plot.jl b/src/plot.jl index 8b9c8c44a..c38d956ae 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -2,7 +2,7 @@ mutable struct CurrentPlot nullableplot::Union{AbstractPlot, Nothing} end -const CURRENT_PLOT = CurrentPlot(Union{AbstractPlot, Nothing}()) +const CURRENT_PLOT = CurrentPlot(nothing) isplotnull() = isnull(CURRENT_PLOT.nullableplot) @@ -16,7 +16,7 @@ function current() end get(CURRENT_PLOT.nullableplot) end -current(plot::AbstractPlot) = (CURRENT_PLOT.nullableplot = Nullable(plot)) +current(plot::AbstractPlot) = (CURRENT_PLOT.nullableplot = plot) # --------------------------------------------------------- From 1f4d9166f36b1dc2a54a21dc35f4876beef07e7f Mon Sep 17 00:00:00 2001 From: Ederag Date: Sat, 12 May 2018 19:33:59 +0200 Subject: [PATCH 2/4] Void => Nothing --- src/args.jl | 6 +++--- src/axes.jl | 2 +- src/backends/gr.jl | 2 +- src/backends/hdf5.jl | 10 +++++----- src/backends/inspectdr.jl | 6 +++--- src/components.jl | 4 ++-- src/deprecated/colors.jl | 6 +++--- src/deprecated/series_args.jl | 18 +++++++++--------- src/pipeline.jl | 2 +- src/series.jl | 18 +++++++++--------- src/utils.jl | 4 ++-- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/args.jl b/src/args.jl index 9bfed7cb5..bbe8646e3 100644 --- a/src/args.jl +++ b/src/args.jl @@ -188,7 +188,7 @@ const _allGridSyms = [:x, :y, :z, :all, :both, :on, :yes, :show, :none, :off, :no, :hide] const _allGridArgs = [_allGridSyms; string.(_allGridSyms); nothing] -hasgrid(arg::Void, letter) = false +hasgrid(arg::Nothing, letter) = false hasgrid(arg::Bool, letter) = arg function hasgrid(arg::Symbol, letter) if arg in _allGridSyms @@ -206,7 +206,7 @@ const _allShowaxisSyms = [:x, :y, :z, :all, :both, :on, :yes, :show, :off, :no, :hide] const _allShowaxisArgs = [_allGridSyms; string.(_allGridSyms)] -showaxis(arg::Void, letter) = false +showaxis(arg::Nothing, letter) = false showaxis(arg::Bool, letter) = arg function showaxis(arg::Symbol, letter) if arg in _allGridSyms @@ -1129,7 +1129,7 @@ function convertLegendValue(val::Symbol) end end 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::AbstractArray) = map(convertLegendValue, v) diff --git a/src/axes.jl b/src/axes.jl index db4137e3e..042dd8e29 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -307,7 +307,7 @@ function expand_extrema!(axis::Axis, v::Number) end # 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] diff --git a/src/backends/gr.jl b/src/backends/gr.jl index b742eb156..d58eefd99 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -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_textcolor(c) = GR.settextcolorind(gr_getcolorind(_cycle(c,1))) gr_set_transparency(α::Real) = GR.settransparency(clamp(α, 0, 1)) -function gr_set_transparency(::Void) end +function gr_set_transparency(::Nothing) end # -------------------------------------------------------------------------------------- diff --git a/src/backends/hdf5.jl b/src/backends/hdf5.jl index d68bfef62..e1fc26e88 100644 --- a/src/backends/hdf5.jl +++ b/src/backends/hdf5.jl @@ -39,7 +39,7 @@ struct HDF5PlotNative; end #Indentifies a data element that can natively be hand struct HDF5CTuple; end #Identifies a "complex" tuple structure mutable struct HDF5Plot_PlotRef - ref::Union{Plot, Void} + ref::Union{Plot, Nothing} end @@ -148,7 +148,7 @@ function _initialize_backend(::HDF5Backend) #Possible element types of high-level data types: const telem2str = Dict{String, Type}( "NATIVE" => HDF5PlotNative, - "VOID" => Void, + "VOID" => Nothing, "BOOL" => Bool, "SYMBOL" => Symbol, "TUPLE" => Tuple, @@ -319,9 +319,9 @@ function _hdf5plot_gwrite(grp, k::String, v::Array{Any}) warn("Cannot write Array: $k=$v") end =# -function _hdf5plot_gwrite(grp, k::String, v::Void) +function _hdf5plot_gwrite(grp, k::String, v::Nothing) grp[k] = 0 - _hdf5plot_writetype(grp, k, Void) + _hdf5plot_writetype(grp, k, Nothing) end function _hdf5plot_gwrite(grp, k::String, v::Bool) grp[k] = Int(v) @@ -489,7 +489,7 @@ function _hdf5plot_readcount(grp) #Read directly from group end _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{Symbol}, v) = Symbol(v) _hdf5plot_convert(T::Type{Tuple}, v) = tuple(v...) #With Vector{T<:Number} diff --git a/src/backends/inspectdr.jl b/src/backends/inspectdr.jl index d0d3e2856..62023f14f 100644 --- a/src/backends/inspectdr.jl +++ b/src/backends/inspectdr.jl @@ -171,8 +171,8 @@ function _initialize_backend(::InspectDRBackend; kw...) ) mutable struct InspecDRPlotRef - mplot::Union{Void, InspectDR.Multiplot} - gui::Union{Void, InspectDR.GtkPlot} + mplot::Union{Nothing, InspectDR.Multiplot} + gui::Union{Nothing, InspectDR.GtkPlot} end _inspectdr_getmplot(::Any) = nothing @@ -506,7 +506,7 @@ const _inspectdr_mimeformats_nodpi = Dict( # "application/postscript" => "ps", #TODO: support once Cairo supports PSSurface "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")) function _inspectdr_show(io::IO, mime::MIME, mplot, w, h) InspectDR._show(io, mime, mplot, Float64(w), Float64(h)) diff --git a/src/components.jl b/src/components.jl index 343582f3e..697500670 100644 --- a/src/components.jl +++ b/src/components.jl @@ -468,7 +468,7 @@ function series_annotations(strs::AbstractVector, args...) SeriesAnnotations(strs, fnt, shp, scalefactor) end series_annotations(anns::SeriesAnnotations) = anns -series_annotations(::Void) = nothing +series_annotations(::Nothing) = nothing function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels) anns = series[:series_annotations] @@ -531,7 +531,7 @@ function Base.next(ea::EachAnn, i) ((_cycle(ea.x,i), _cycle(ea.y,i), str, fnt), i+1) end -annotations(::Void) = [] +annotations(::Nothing) = [] annotations(anns::AVec) = anns annotations(anns) = Any[anns] annotations(sa::SeriesAnnotations) = sa diff --git a/src/deprecated/colors.jl b/src/deprecated/colors.jl index 8247529a8..b4ed15561 100644 --- a/src/deprecated/colors.jl +++ b/src/deprecated/colors.jl @@ -51,7 +51,7 @@ convertColor(c::Symbol) = parse(Colorant, string(c)) convertColor(c::Colorant) = c convertColor(cvec::AbstractVector) = map(convertColor, cvec) 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) function convertColor(c, α::Real) @@ -59,7 +59,7 @@ function convertColor(c, α::Real) RGBA(RGB(getColor(c)), α) end convertColor(cs::AVec, α::Real) = map(c -> convertColor(c, α), cs) -convertColor(c, α::Void) = convertColor(c) +convertColor(c, α::Nothing) = convertColor(c) # backup... try to convert getColor(c) = convertColor(c) @@ -247,7 +247,7 @@ ColorWrapper(s::Symbol; alpha = nothing) = ColorWrapper(convertColor(parse(Color getColor(scheme::ColorWrapper, idx::Int) = scheme.c getColorZ(scheme::ColorWrapper, z::Real) = scheme.c -convertColor(c::ColorWrapper, α::Void) = c.c +convertColor(c::ColorWrapper, α::Nothing) = c.c # -------------------------------------------------------------- diff --git a/src/deprecated/series_args.jl b/src/deprecated/series_args.jl index b5b025949..12c3e3548 100644 --- a/src/deprecated/series_args.jl +++ b/src/deprecated/series_args.jl @@ -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)) # missing -convertToAnyVector(v::Void, d::KW) = Any[nothing], nothing +convertToAnyVector(v::Nothing, d::KW) = Any[nothing], nothing # fixed number of blank series 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 # 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::Void, y, z) = 1:size(y,1) +compute_x(x::Nothing, y::Nothing, z) = 1:size(z,1) +compute_x(x::Nothing, y, z) = 1:size(y,1) compute_x(x::Function, y, z) = map(x, y) compute_x(x, y, z) = copy(x) -# compute_y(x::Void, y::Function, z) = error() -compute_y(x::Void, y::Void, z) = 1:size(z,2) +# compute_y(x::Nothing, y::Function, z) = error() +compute_y(x::Nothing, y::Nothing, z) = 1:size(z,2) compute_y(x, y::Function, z) = map(y, x) compute_y(x, y, z) = copy(y) compute_z(x, y, z::Function) = map(z, x, y) 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) nobigs(v::AVec{BigFloat}) = map(Float64, v) @@ -92,8 +92,8 @@ nobigs(v) = v end # 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::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::Void, y::Void, z::Void) = error("x/y/z are all nothing!") +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::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::Nothing, y::Nothing, z::Nothing) = error("x/y/z are all nothing!") # -------------------------------------------------------------------- diff --git a/src/pipeline.jl b/src/pipeline.jl index 931aa76e2..cb001a7fa 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -329,7 +329,7 @@ function _override_seriestype_check(d::KW, st::Symbol) # do we want to override the series type? if !is3d(st) 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) d[:seriestype] = st end diff --git a/src/series.jl b/src/series.jl index 8b3f19bb1..e82d42a96 100644 --- a/src/series.jl +++ b/src/series.jl @@ -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))") # missing -convertToAnyVector(v::Void, d::KW) = Any[nothing], nothing +convertToAnyVector(v::Nothing, d::KW) = Any[nothing], nothing # fixed number of blank series convertToAnyVector(n::Integer, d::KW) = Any[zeros(0) for i in 1:n], nothing @@ -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 # 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::Void, y, z) = 1:size(y,1) +compute_x(x::Nothing, y::Nothing, z) = 1:size(z,1) +compute_x(x::Nothing, y, z) = 1:size(y,1) compute_x(x::Function, y, z) = map(x, y) compute_x(x, y, z) = copy(x) -# compute_y(x::Void, y::Function, z) = error() -compute_y(x::Void, y::Void, z) = 1:size(z,2) +# compute_y(x::Nothing, y::Function, z) = error() +compute_y(x::Nothing, y::Nothing, z) = 1:size(z,2) compute_y(x, y::Function, z) = map(y, x) compute_y(x, y, z) = copy(y) compute_z(x, y, z::Function) = map(z, x, y) 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) nobigs(v::AVec{BigFloat}) = map(Float64, v) @@ -99,9 +99,9 @@ nobigs(v) = v end # 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::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::Void, y::Void, z::Void) = error("x/y/z are all nothing!") +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::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::Nothing, y::Nothing, z::Nothing) = error("x/y/z are all nothing!") # -------------------------------------------------------------------- diff --git a/src/utils.jl b/src/utils.jl index 6153f4b4d..5ef0652dd 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -255,7 +255,7 @@ float_extended_type(x::AbstractArray{T}) where {T<:Real} = Float64 nop() = nothing notimpl() = error("This has not been implemented yet") -isnothing(x::Void) = true +isnothing(x::Nothing) = true isnothing(x) = false _cycle(wrapper::InputWrapper, idx::Int) = wrapper.obj @@ -828,7 +828,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 tovec(v::AbstractVector) = v -tovec(v::Void) = zeros(0) +tovec(v::Nothing) = zeros(0) function getxy(plt::Plot, i::Integer) d = plt.series_list[i].d From f87ab4082d751f20406daacef7da5ff56ef4dad3 Mon Sep 17 00:00:00 2001 From: Ederag Date: Sat, 12 May 2018 19:46:01 +0200 Subject: [PATCH 3/4] isdefined(:GLPlot) => @isdefined(GLPlot) Attempt at solving the following Warning: `isdefined(:symbol)` is deprecated, use `@isdefined symbol` instead But the warning remains --- src/backends/glvisualize.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index b8a4ed047..8f7fd565d 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -1181,7 +1181,7 @@ function _display(plt::Plot{GLVisualizeBackend}, visible = true) if haskey(d, :hover) && !(d[:hover] in (false, :none, nothing)) hover(vis, d[:hover], sp_screen) end - if isdefined(:GLPlot) && isdefined(Main.GLPlot, :(register_plot!)) + if @isdefined(GLPlot) && isdefined(Main.GLPlot, :(register_plot!)) del_signal = Main.GLPlot.register_plot!(vis, sp_screen, create_gizmo=false) append!(_glplot_deletes, del_signal) end From c140ea561d369d2c8692be734c0809d15b80e5ba Mon Sep 17 00:00:00 2001 From: Ederag Date: Sat, 12 May 2018 20:11:28 +0200 Subject: [PATCH 4/4] linspace => range solves Warning: `linspace(start, stop, length::Integer)` is deprecated, use `range(start, stop=stop, length=length)` instead. --- src/arg_desc.jl | 2 +- src/axes.jl | 4 ++-- src/backends/glvisualize.jl | 4 ++-- src/backends/gr.jl | 6 +++--- src/backends/plotly.jl | 2 +- src/components.jl | 4 ++-- src/deprecated/color_gradients.jl | 2 +- src/deprecated/colors.jl | 24 ++++++++++++------------ src/examples.jl | 14 +++++++------- src/recipes.jl | 2 +- src/series.jl | 4 ++-- src/themes.jl | 4 ++-- src/utils.jl | 4 ++-- 13 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/arg_desc.jl b/src/arg_desc.jl index 199190dbf..1adcdc7b9 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -21,7 +21,7 @@ const _arg_desc = KW( :markerstrokewidth => "Number. Width of the marker stroke (border. in pixels)", :markerstrokecolor => "Color Type. Color of the marker stroke (border). `:match` will take the value from `:foreground_color_subplot`.", :markerstrokealpha => "Number in [0,1]. The alpha/opacity override for the marker stroke (border). `nothing` (the default) means it will take the alpha value of markerstrokecolor.", -:bins => "Integer, NTuple{2,Integer}, AbstractVector or Symbol. Default is :auto (the Freedman-Diaconis rule). For histogram-types, defines the approximate number of bins to aim for, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd). For fine-grained control pass a Vector of break values, e.g. `linspace(extrema(x)..., 25)`", +:bins => "Integer, NTuple{2,Integer}, AbstractVector or Symbol. Default is :auto (the Freedman-Diaconis rule). For histogram-types, defines the approximate number of bins to aim for, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd). For fine-grained control pass a Vector of break values, e.g. `range(min(x); stop=max(x), length=25)`", :smooth => "Bool. Add a regression line?", :group => "AbstractVector. Data is split into a separate series, one for each unique value in `group`.", :x => "Various. Input data. First Dimension", diff --git a/src/axes.jl b/src/axes.jl index 042dd8e29..13bb8f820 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -250,11 +250,11 @@ function get_ticks(axis::Axis) # discrete ticks... n = length(dvals) 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)] elseif ticks == :all 1:n elseif typeof(ticks) <: Int - Int[round(Int,i) for i in linspace(1, n, ticks)] + Int[round(Int,i) for i in range(1; stop=n, length=ticks)] end axis[:continuous_values][rng], dvals[rng] elseif typeof(ticks) <: Symbol diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index 8f7fd565d..c20cf8c26 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -397,7 +397,7 @@ function gappy(x, ps) return last(ps) - x end function ticks(points, resolution) - Float16[gappy(x, points) for x = linspace(first(points),last(points), resolution)] + Float16[gappy(x, points) for x in range(first(points); stop=last(points), length=resolution)] end @@ -901,7 +901,7 @@ function gl_boxplot(d, kw_args) # filter y values = y[filter(i -> _cycle(x,i) == glabel, 1:length(y))] # 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 n = Plots.notch_width(q2, q4, length(values)) # warn on inverted notches? diff --git a/src/backends/gr.jl b/src/backends/gr.jl index d58eefd99..066f09a4b 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -491,7 +491,7 @@ function gr_colorbar(sp::Subplot, clims) xmin, xmax = gr_xy_axislims(sp)[1:2] gr_set_viewport_cmap(sp) 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.setwindow(xmin, xmax, clims[1], clims[2]) GR.cellarray(xmin, xmax, clims[2], clims[1], 1, length(l), l) @@ -537,7 +537,7 @@ const _gr_gradient_alpha = ones(256) function gr_set_gradient(c) 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] GR.setcolorrep(999+i, red(c), green(c), blue(c)) _gr_gradient_alpha[i] = alpha(c) @@ -1059,7 +1059,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) if typeof(series[:levels]) <: AbstractArray h = series[:levels] 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 if series[:fillrange] != nothing GR.surface(x, y, z, GR.OPTION_CELL_ARRAY) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index f1daf3d7a..4eeed3b3b 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -447,7 +447,7 @@ function plotly_colorscale(c::AbstractVector{<:RGBA}, α) if length(c) == 1 return [[0.0, rgba_string(plot_color(c[1], α))], [1.0, rgba_string(plot_color(c[1], α))]] 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)] end end diff --git a/src/components.jl b/src/components.jl index 697500670..762e6eca7 100644 --- a/src/components.jl +++ b/src/components.jl @@ -58,7 +58,7 @@ end "get an array of tuples of points on a circle with radius `r`" 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 "interleave 2 vectors into each other (like a zipper's teeth)" @@ -747,7 +747,7 @@ end @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(first(range); stop=last(range), length=n)) # 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] diff --git a/src/deprecated/color_gradients.jl b/src/deprecated/color_gradients.jl index 37e7c4efe..4ca342c9e 100644 --- a/src/deprecated/color_gradients.jl +++ b/src/deprecated/color_gradients.jl @@ -19,7 +19,7 @@ # work. If not, see . 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] end diff --git a/src/deprecated/colors.jl b/src/deprecated/colors.jl index b4ed15561..5f1db3b8e 100644 --- a/src/deprecated/colors.jl +++ b/src/deprecated/colors.jl @@ -13,15 +13,15 @@ function cgrad(arg, values = nothing; alpha = nothing, scale = :identity) values = if values != nothing values elseif scale in (:log, :log10) - log10(linspace(1,10,30)) + log10(range(1; stop=10, length=30)) elseif scale == :log2 - log2(linspace(1,2,30)) + log2(range(1; stop=2, length=30)) elseif scale == :ln - log(linspace(1,pi,30)) + log(range(1; stop=pi, length=30)) elseif scale in (:exp, :exp10) - (exp10(linspace(0,1,30)) - 1) / 9 + (exp10(range(0; stop=1, length=30)) - 1) / 9 else - linspace(0, 1, length(colors)) + range(0; stop=1, length=length(colors)) end ColorGradient(colors, values) end @@ -113,20 +113,20 @@ struct ColorGradient <: ColorScheme colors::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) return new(convertColor(cs,alpha), collect(vals)) end # # otherwise interpolate evenly between the minval and maxval # minval, maxval = minimum(vals), maximum(vals) - # vs = Float64[interpolate(minval, maxval, w) for w in linspace(0, 1, length(cs))] + # vs = Float64[interpolate(minval, maxval, w) for w in range(0; stop=1, length=length(cs))] # new(convertColor(cs,alpha), vs) # 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) - 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) end end @@ -142,12 +142,12 @@ 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)))) cs = _gradients[s] if vals == 0:0 - vals = linspace(0, 1, length(cs)) + vals = range(0; stop=1, length=length(cs)) end ColorGradient(cs, vals; kw...) end -# function ColorGradient{T<:Real}(cs::AVec, vals::AVec{T} = linspace(0, 1, length(cs)); kw...) +# function ColorGradient{T<:Real}(cs::AVec, vals::AVec{T} = range(0; stop=1, length=length(cs)); kw...) # ColorGradient(map(convertColor, cs), vals; kw...) # end @@ -332,7 +332,7 @@ function generate_colorgradient(bgcolor = colorant"white"; seed_colors, lchoices=Float64[lightness], cchoices=Float64[chroma], - hchoices=linspace(0, 340, 20) + hchoices=range(0; stop=340, length=20) )[2:end] gradient_from_list(colors) end diff --git a/src/examples.jl b/src/examples.jl index 57ed7b3ec..670c86551 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -29,7 +29,7 @@ animation. [:(begin p = plot([sin,cos], zeros(0), leg=false) 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)]) frame(anim) end @@ -156,7 +156,7 @@ PlotExample("Marker types", markers = filter(m -> m in Plots.supported_markers(), Plots._shape_keys) markers = reshape(markers, 1, 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) scatter(x, y, m=(8,:auto), lab=map(string,markers), bg=:linen, xlim=(0,10), ylim=(0,10)) end)] @@ -238,7 +238,7 @@ y = rand(10) plot(y, annotations = (3,y[3],text("this is #3",:left)), leg=false) annotate!([(5, y[5], text("this is #5",16,:red,:center)), (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", text("data",:green)]) end)] @@ -291,7 +291,7 @@ PlotExample("3D", "", [:(begin n = 100 - ts = linspace(0,8π,n) + ts = range(0; stop=8π, length=n) x = ts .* map(cos,ts) y = 0.1ts .* map(sin,ts) z = 1:n @@ -323,7 +323,7 @@ PlotExample("Groups and Subplots", PlotExample("Polar Plots", "", [:(begin - Θ = linspace(0,1.5π,100) + Θ = range(0; stop=1.5π, length=100) r = abs.(0.1randn(100)+sin.(3Θ)) plot(Θ, r, proj=:polar, m=2) end)] @@ -368,7 +368,7 @@ PlotExample("Animation with subplots", plot(log,1,xlims=(1,10π),ylims=(0,5),leg=false),layout=l) 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)])) frame(anim) 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. """, [:(begin - t = linspace(0, 1, 100) + t = range(0; stop=1, length=100) θ = 6π .* t x = t .* cos.(θ) y = t .* sin.(θ) diff --git a/src/recipes.jl b/src/recipes.jl index 2393f6a86..11e1b90dc 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -284,7 +284,7 @@ end # where the points are the control points of the curve for rng in iter_segments(args...) length(rng) < 2 && continue - ts = linspace(0, 1, npoints) + ts = range(0; stop=1, length=npoints) nanappend!(newx, map(t -> bezier_value(_cycle(x,rng), t), ts)) nanappend!(newy, map(t -> bezier_value(_cycle(y,rng), t), ts)) if z != nothing diff --git a/src/series.jl b/src/series.jl index e82d42a96..cfcb11872 100644 --- a/src/series.jl +++ b/src/series.jl @@ -518,7 +518,7 @@ end xs, fs end @recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, u::AVec) where {F<:Function,G<:Function} = mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u) -@recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, umin::Number, umax::Number, n = 200) where {F<:Function,G<:Function} = fx, fy, linspace(umin, umax, n) +@recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, umin::Number, umax::Number, n = 200) where {F<:Function,G<:Function} = fx, fy, range(umin; stop=umax, length=n) # # # special handling... 3D parametric function(s) @@ -526,7 +526,7 @@ end mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u), mapFuncOrFuncs(fz, u) end @recipe function f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, fz::FuncOrFuncs{H}, umin::Number, umax::Number, numPoints = 200) where {F<:Function,G<:Function,H<:Function} - fx, fy, fz, linspace(umin, umax, numPoints) + fx, fy, fz, range(umin; stop=umax, length=numPoints) end # diff --git a/src/themes.jl b/src/themes.jl index c2b2aee12..491642131 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -132,7 +132,7 @@ _get_showtheme_args(thm::Symbol, func::Symbol) = thm, get(_color_functions, func f(r) = sin(r) / r _norm(x, y) = norm([x, y]) - x = y = linspace(-3π, 3π, 30) + x = y = range(-3π; stop=3π, length=30) z = f.(_norm.(x, y')) wi = 2:3:30 @@ -152,7 +152,7 @@ _get_showtheme_args(thm::Symbol, func::Symbol) = thm, get(_color_functions, func end n = 100 - ts = linspace(0, 10π, n) + ts = range(0; stop=10π, length=n) x = ts .* cos.(ts) y = (0.1ts) .* sin.(ts) z = 1:n diff --git a/src/utils.jl b/src/utils.jl index 5ef0652dd..bb637239c 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -4,7 +4,7 @@ calcMidpoints(edges::AbstractVector) = Float64[0.5 * (edges[i] + edges[i+1]) for "Make histogram-like bins of data" function binData(data, nbins) lo, hi = ignorenan_extrema(data) - edges = collect(linspace(lo, hi, nbins+1)) + edges = collect(range(lo; stop=hi, length=nbins+1)) midpoints = calcMidpoints(edges) buckets = Int[max(2, min(searchsortedfirst(edges, x), length(edges)))-1 for x in data] counts = zeros(Int, length(midpoints)) @@ -119,7 +119,7 @@ function replace_image_with_heatmap(z::Array{T}) where T<:Colorant n, m = size(z) # idx = 0 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 = zeros(n, m) # for i=1:n, j=1:m