Merge pull request #1036 from JuliaPlots/fbot/deps

Fix deprecations
This commit is contained in:
Michael Krabbe Borregaard 2017-10-17 21:45:13 +02:00 committed by GitHub
commit eecd14f53a
28 changed files with 227 additions and 227 deletions

View File

@ -110,13 +110,13 @@ export
# --------------------------------------------------------- # ---------------------------------------------------------
import NaNMath # define functions that ignores NaNs. To overcome the destructive effects of https://github.com/JuliaLang/julia/pull/12563 import NaNMath # define functions that ignores NaNs. To overcome the destructive effects of https://github.com/JuliaLang/julia/pull/12563
ignorenan_minimum{F<:AbstractFloat}(x::AbstractArray{F}) = NaNMath.minimum(x) ignorenan_minimum(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.minimum(x)
ignorenan_minimum(x) = Base.minimum(x) ignorenan_minimum(x) = Base.minimum(x)
ignorenan_maximum{F<:AbstractFloat}(x::AbstractArray{F}) = NaNMath.maximum(x) ignorenan_maximum(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.maximum(x)
ignorenan_maximum(x) = Base.maximum(x) ignorenan_maximum(x) = Base.maximum(x)
ignorenan_mean{F<:AbstractFloat}(x::AbstractArray{F}) = NaNMath.mean(x) ignorenan_mean(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.mean(x)
ignorenan_mean(x) = Base.mean(x) ignorenan_mean(x) = Base.mean(x)
ignorenan_extrema{F<:AbstractFloat}(x::AbstractArray{F}) = NaNMath.extrema(x) ignorenan_extrema(x::AbstractArray{F}) where {F<:AbstractFloat} = NaNMath.extrema(x)
ignorenan_extrema(x) = Base.extrema(x) ignorenan_extrema(x) = Base.extrema(x)
# --------------------------------------------------------- # ---------------------------------------------------------
@ -215,13 +215,13 @@ xlabel!(s::AbstractString; kw...) = plot!(; xlabel = s, kw...)
ylabel!(s::AbstractString; kw...) = plot!(; ylabel = s, kw...) ylabel!(s::AbstractString; kw...) = plot!(; ylabel = s, kw...)
"Set xlims for an existing plot" "Set xlims for an existing plot"
xlims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; xlims = lims, kw...) xlims!(lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(; xlims = lims, kw...)
"Set ylims for an existing plot" "Set ylims for an existing plot"
ylims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; ylims = lims, kw...) ylims!(lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(; ylims = lims, kw...)
"Set zlims for an existing plot" "Set zlims for an existing plot"
zlims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; zlims = lims, kw...) zlims!(lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(; zlims = lims, kw...)
xlims!(xmin::Real, xmax::Real; kw...) = plot!(; xlims = (xmin,xmax), kw...) xlims!(xmin::Real, xmax::Real; kw...) = plot!(; xlims = (xmin,xmax), kw...)
ylims!(ymin::Real, ymax::Real; kw...) = plot!(; ylims = (ymin,ymax), kw...) ylims!(ymin::Real, ymax::Real; kw...) = plot!(; ylims = (ymin,ymax), kw...)
@ -229,19 +229,19 @@ zlims!(zmin::Real, zmax::Real; kw...) = plot!(; zlims = (zmi
"Set xticks for an existing plot" "Set xticks for an existing plot"
xticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; xticks = v, kw...) xticks!(v::AVec{T}; kw...) where {T<:Real} = plot!(; xticks = v, kw...)
"Set yticks for an existing plot" "Set yticks for an existing plot"
yticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; yticks = v, kw...) yticks!(v::AVec{T}; kw...) where {T<:Real} = plot!(; yticks = v, kw...)
xticks!{T<:Real,S<:AbstractString}( xticks!(
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; xticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) where {T<:Real,S<:AbstractString} = plot!(; xticks = (ticks,labels), kw...)
yticks!{T<:Real,S<:AbstractString}( yticks!(
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; yticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) where {T<:Real,S<:AbstractString} = plot!(; yticks = (ticks,labels), kw...)
"Add annotations to an existing plot" "Add annotations to an existing plot"
annotate!(anns...; kw...) = plot!(; annotation = anns, kw...) annotate!(anns...; kw...) = plot!(; annotation = anns, kw...)
annotate!{T<:Tuple}(anns::AVec{T}; kw...) = plot!(; annotation = anns, kw...) annotate!(anns::AVec{T}; kw...) where {T<:Tuple} = plot!(; annotation = anns, kw...)
"Flip the current plots' x axis" "Flip the current plots' x axis"
xflip!(flip::Bool = true; kw...) = plot!(; xflip = flip, kw...) xflip!(flip::Bool = true; kw...) = plot!(; xflip = flip, kw...)
@ -261,22 +261,22 @@ let PlotOrSubplot = Union{Plot, Subplot}
title!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; title = s, kw...) title!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; title = s, kw...)
xlabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; xlabel = s, kw...) xlabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; xlabel = s, kw...)
ylabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; ylabel = s, kw...) ylabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; ylabel = s, kw...)
xlims!{T<:Real,S<:Real}(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) = plot!(plt; xlims = lims, kw...) xlims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; xlims = lims, kw...)
ylims!{T<:Real,S<:Real}(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) = plot!(plt; ylims = lims, kw...) ylims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; ylims = lims, kw...)
zlims!{T<:Real,S<:Real}(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) = plot!(plt; zlims = lims, kw...) zlims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; zlims = lims, kw...)
xlims!(plt::PlotOrSubplot, xmin::Real, xmax::Real; kw...) = plot!(plt; xlims = (xmin,xmax), kw...) xlims!(plt::PlotOrSubplot, xmin::Real, xmax::Real; kw...) = plot!(plt; xlims = (xmin,xmax), kw...)
ylims!(plt::PlotOrSubplot, ymin::Real, ymax::Real; kw...) = plot!(plt; ylims = (ymin,ymax), kw...) ylims!(plt::PlotOrSubplot, ymin::Real, ymax::Real; kw...) = plot!(plt; ylims = (ymin,ymax), kw...)
zlims!(plt::PlotOrSubplot, zmin::Real, zmax::Real; kw...) = plot!(plt; zlims = (zmin,zmax), kw...) zlims!(plt::PlotOrSubplot, zmin::Real, zmax::Real; kw...) = plot!(plt; zlims = (zmin,zmax), kw...)
xticks!{T<:Real}(plt::PlotOrSubplot, ticks::AVec{T}; kw...) = plot!(plt; xticks = ticks, kw...) xticks!(plt::PlotOrSubplot, ticks::AVec{T}; kw...) where {T<:Real} = plot!(plt; xticks = ticks, kw...)
yticks!{T<:Real}(plt::PlotOrSubplot, ticks::AVec{T}; kw...) = plot!(plt; yticks = ticks, kw...) yticks!(plt::PlotOrSubplot, ticks::AVec{T}; kw...) where {T<:Real} = plot!(plt; yticks = ticks, kw...)
xticks!{T<:Real,S<:AbstractString}(plt::PlotOrSubplot, xticks!(plt::PlotOrSubplot,
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; xticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) where {T<:Real,S<:AbstractString} = plot!(plt; xticks = (ticks,labels), kw...)
yticks!{T<:Real,S<:AbstractString}(plt::PlotOrSubplot, yticks!(plt::PlotOrSubplot,
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; yticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) where {T<:Real,S<:AbstractString} = plot!(plt; yticks = (ticks,labels), kw...)
xgrid!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xgrid = args, kw...) xgrid!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xgrid = args, kw...)
ygrid!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; ygrid = args, kw...) ygrid!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; ygrid = args, kw...)
annotate!(plt::PlotOrSubplot, anns...; kw...) = plot!(plt; annotation = anns, kw...) annotate!(plt::PlotOrSubplot, anns...; kw...) = plot!(plt; annotation = anns, kw...)
annotate!{T<:Tuple}(plt::PlotOrSubplot, anns::AVec{T}; kw...) = plot!(plt; annotation = anns, kw...) annotate!(plt::PlotOrSubplot, anns::AVec{T}; kw...) where {T<:Tuple} = plot!(plt; annotation = anns, kw...)
xflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; xflip = flip, kw...) xflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; xflip = flip, kw...)
yflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; yflip = flip, kw...) yflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; yflip = flip, kw...)
xaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xaxis = args, kw...) xaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xaxis = args, kw...)

View File

@ -1,5 +1,5 @@
"Represents an animation object" "Represents an animation object"
immutable Animation struct Animation
dir::String dir::String
frames::Vector{String} frames::Vector{String}
end end
@ -14,7 +14,7 @@ end
Add a plot (the current plot if not specified) to an existing animation Add a plot (the current plot if not specified) to an existing animation
""" """
function frame{P<:AbstractPlot}(anim::Animation, plt::P=current()) function frame(anim::Animation, plt::P=current()) where P<:AbstractPlot
i = length(anim.frames) + 1 i = length(anim.frames) + 1
filename = @sprintf("%06d.png", i) filename = @sprintf("%06d.png", i)
png(plt, joinpath(anim.dir, filename)) png(plt, joinpath(anim.dir, filename))
@ -25,7 +25,7 @@ giffn() = (isijulia() ? "tmp.gif" : tempname()*".gif")
movfn() = (isijulia() ? "tmp.mov" : tempname()*".mov") movfn() = (isijulia() ? "tmp.mov" : tempname()*".mov")
mp4fn() = (isijulia() ? "tmp.mp4" : tempname()*".mp4") mp4fn() = (isijulia() ? "tmp.mp4" : tempname()*".mp4")
type FrameIterator mutable struct FrameIterator
itr itr
every::Int every::Int
kw kw
@ -54,7 +54,7 @@ end
# ----------------------------------------------- # -----------------------------------------------
"Wraps the location of an animated gif so that it can be displayed" "Wraps the location of an animated gif so that it can be displayed"
immutable AnimatedGif struct AnimatedGif
filename::String filename::String
end end

View File

@ -889,7 +889,7 @@ end
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
"A special type that will break up incoming data into groups, and allow for easier creation of grouped plots" "A special type that will break up incoming data into groups, and allow for easier creation of grouped plots"
type GroupBy mutable struct GroupBy
groupLabels::Vector # length == numGroups groupLabels::Vector # length == numGroups
groupIds::Vector{Vector{Int}} # list of indices for each group groupIds::Vector{Vector{Int}} # list of indices for each group
end end
@ -916,7 +916,7 @@ function extractGroupArgs(vs::Tuple, args...)
end end
# expecting a mapping of "group label" to "group indices" # expecting a mapping of "group label" to "group indices"
function extractGroupArgs{T, V<:AVec{Int}}(idxmap::Dict{T,V}, args...) function extractGroupArgs(idxmap::Dict{T,V}, args...) where {T, V<:AVec{Int}}
groupLabels = sortedkeys(idxmap) groupLabels = sortedkeys(idxmap)
groupIds = Vector{Int}[collect(idxmap[k]) for k in groupLabels] groupIds = Vector{Int}[collect(idxmap[k]) for k in groupLabels]
GroupBy(groupLabels, groupIds) GroupBy(groupLabels, groupIds)
@ -1007,7 +1007,7 @@ function convertLegendValue(val::Symbol)
end end
convertLegendValue(val::Bool) = val ? :best : :none convertLegendValue(val::Bool) = val ? :best : :none
convertLegendValue(val::Void) = :none convertLegendValue(val::Void) = :none
convertLegendValue{S<:Real, T<:Real}(v::Tuple{S,T}) = 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

@ -293,13 +293,13 @@ expand_extrema!(axis::Axis, ::Void) = axis[:extrema]
expand_extrema!(axis::Axis, ::Bool) = axis[:extrema] expand_extrema!(axis::Axis, ::Bool) = axis[:extrema]
function expand_extrema!{MIN<:Number,MAX<:Number}(axis::Axis, v::Tuple{MIN,MAX}) function expand_extrema!(axis::Axis, v::Tuple{MIN,MAX}) where {MIN<:Number,MAX<:Number}
ex = axis[:extrema] ex = axis[:extrema]
ex.emin = NaNMath.min(v[1], ex.emin) ex.emin = NaNMath.min(v[1], ex.emin)
ex.emax = NaNMath.max(v[2], ex.emax) ex.emax = NaNMath.max(v[2], ex.emax)
ex ex
end end
function expand_extrema!{N<:Number}(axis::Axis, v::AVec{N}) function expand_extrema!(axis::Axis, v::AVec{N}) where N<:Number
ex = axis[:extrema] ex = axis[:extrema]
for vi in v for vi in v
expand_extrema!(ex, vi) expand_extrema!(ex, vi)

View File

@ -1,5 +1,5 @@
immutable NoBackend <: AbstractBackend end struct NoBackend <: AbstractBackend end
const _backendType = Dict{Symbol, DataType}(:none => NoBackend) const _backendType = Dict{Symbol, DataType}(:none => NoBackend)
const _backendSymbol = Dict{DataType, Symbol}(NoBackend => :none) const _backendSymbol = Dict{DataType, Symbol}(NoBackend => :none)
@ -18,7 +18,7 @@ macro init_backend(s)
sym = Symbol(str) sym = Symbol(str)
T = Symbol(string(s) * "Backend") T = Symbol(string(s) * "Backend")
esc(quote esc(quote
immutable $T <: AbstractBackend end struct $T <: AbstractBackend end
export $sym export $sym
$sym(; kw...) = (default(; kw...); backend(Symbol($str))) $sym(; kw...) = (default(; kw...); backend(Symbol($str)))
backend_name(::$T) = Symbol($str) backend_name(::$T) = Symbol($str)
@ -123,7 +123,7 @@ _update_plot_object(plt::Plot) = nothing
# --------------------------------------------------------- # ---------------------------------------------------------
type CurrentBackend mutable struct CurrentBackend
sym::Symbol sym::Symbol
pkg::AbstractBackend pkg::AbstractBackend
end end

View File

@ -69,9 +69,9 @@ function _initialize_backend(::GLVisualizeBackend; kw...)
import GLVisualize: visualize import GLVisualize: visualize
import Plots.GL import Plots.GL
import UnicodeFun import UnicodeFun
Plots.slice_arg{C<:Colorant}(img::Matrix{C}, idx::Int) = img Plots.slice_arg(img::Matrix{C}, idx::Int) where {C<:Colorant} = img
is_marker_supported(::GLVisualizeBackend, shape::GLVisualize.AllPrimitives) = true is_marker_supported(::GLVisualizeBackend, shape::GLVisualize.AllPrimitives) = true
is_marker_supported{C<:Colorant}(::GLVisualizeBackend, shape::Union{Vector{Matrix{C}}, Matrix{C}}) = 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 const GL = Plots
end end
@ -214,13 +214,13 @@ function extract_limits(sp, d, kw_args)
nothing nothing
end end
to_vec{T <: StaticArrays.StaticVector}(::Type{T}, vec::T) = vec to_vec(::Type{T}, vec::T) where {T <: StaticArrays.StaticVector} = vec
to_vec{T <: StaticArrays.StaticVector}(::Type{T}, s::Number) = T(s) to_vec(::Type{T}, s::Number) where {T <: StaticArrays.StaticVector} = T(s)
to_vec{T <: StaticArrays.StaticVector{2}}(::Type{T}, vec::StaticArrays.StaticVector{3}) = T(vec[1], vec[2]) to_vec(::Type{T}, vec::StaticArrays.StaticVector{3}) where {T <: StaticArrays.StaticVector{2}} = T(vec[1], vec[2])
to_vec{T <: StaticArrays.StaticVector{3}}(::Type{T}, vec::StaticArrays.StaticVector{2}) = T(vec[1], vec[2], 0) to_vec(::Type{T}, vec::StaticArrays.StaticVector{2}) where {T <: StaticArrays.StaticVector{3}} = T(vec[1], vec[2], 0)
to_vec{T <: StaticArrays.StaticVector}(::Type{T}, vecs::AbstractVector) = map(x-> to_vec(T, x), vecs) to_vec(::Type{T}, vecs::AbstractVector) where {T <: StaticArrays.StaticVector} = map(x-> to_vec(T, x), vecs)
function extract_marker(d, kw_args) function extract_marker(d, kw_args)
dim = Plots.is3d(d) ? 3 : 2 dim = Plots.is3d(d) ? 3 : 2
@ -275,7 +275,7 @@ end
function extract_surface(d) function extract_surface(d)
map(_extract_surface, (d[:x], d[:y], d[:z])) map(_extract_surface, (d[:x], d[:y], d[:z]))
end end
function topoints{P}(::Type{P}, array) function topoints(::Type{P}, array) where P
[P(x) for x in zip(array...)] [P(x) for x in zip(array...)]
end end
function extract_points(d) function extract_points(d)
@ -283,7 +283,7 @@ function extract_points(d)
array = (d[:x], d[:y], d[:z])[1:dim] array = (d[:x], d[:y], d[:z])[1:dim]
topoints(Point{dim, Float32}, array) topoints(Point{dim, Float32}, array)
end end
function make_gradient{C <: Colorant}(grad::Vector{C}) function make_gradient(grad::Vector{C}) where C <: Colorant
grad grad
end end
function make_gradient(grad::ColorGradient) function make_gradient(grad::ColorGradient)
@ -338,7 +338,7 @@ function extract_color(d, sym)
end end
gl_color(c::PlotUtils.ColorGradient) = c.colors gl_color(c::PlotUtils.ColorGradient) = c.colors
gl_color{T<:Colorant}(c::Vector{T}) = c gl_color(c::Vector{T}) where {T<:Colorant} = c
gl_color(c::RGBA{Float32}) = c gl_color(c::RGBA{Float32}) = c
gl_color(c::Colorant) = RGBA{Float32}(c) gl_color(c::Colorant) = RGBA{Float32}(c)
@ -1212,7 +1212,7 @@ function gl_image(img, kw_args)
visualize(img, Style(:default), kw_args) visualize(img, Style(:default), kw_args)
end end
function handle_segment{P}(lines, line_segments, points::Vector{P}, segment) function handle_segment(lines, line_segments, points::Vector{P}, segment) where P
(isempty(segment) || length(segment) < 2) && return (isempty(segment) || length(segment) < 2) && return
if length(segment) == 2 if length(segment) == 2
append!(line_segments, view(points, segment)) append!(line_segments, view(points, segment))

View File

@ -482,7 +482,7 @@ function gr_legend_pos(s::Symbol,w,h)
(xpos,ypos) (xpos,ypos)
end end
function gr_legend_pos{S<:Real, T<:Real}(v::Tuple{S,T},w,h) function gr_legend_pos(v::Tuple{S,T},w,h) where {S<:Real, T<:Real}
xpos = v[1] * (viewport_plotarea[2] - viewport_plotarea[1]) + viewport_plotarea[1] xpos = v[1] * (viewport_plotarea[2] - viewport_plotarea[1]) + viewport_plotarea[1]
ypos = v[2] * (viewport_plotarea[4] - viewport_plotarea[3]) + viewport_plotarea[3] ypos = v[2] * (viewport_plotarea[4] - viewport_plotarea[3]) + viewport_plotarea[3]
(xpos,ypos) (xpos,ypos)

View File

@ -32,10 +32,10 @@ Read from .hdf5 file using:
import FixedPointNumbers: N0f8 #In core Julia import FixedPointNumbers: N0f8 #In core Julia
#Dispatch types: #Dispatch types:
immutable HDF5PlotNative; end #Indentifies a data element that can natively be handled by HDF5 struct HDF5PlotNative; end #Indentifies a data element that can natively be handled by HDF5
immutable HDF5CTuple; end #Identifies a "complex" tuple structure struct HDF5CTuple; end #Identifies a "complex" tuple structure
type HDF5Plot_PlotRef mutable struct HDF5Plot_PlotRef
ref::Union{Plot, Void} ref::Union{Plot, Void}
end end
@ -276,11 +276,11 @@ function _hdf5plot_overwritetype(grp, T::Type) #Write directly to group
HDF5.a_delete(grp, _hdf5plot_datatypeid) HDF5.a_delete(grp, _hdf5plot_datatypeid)
HDF5.a_write(grp, _hdf5plot_datatypeid, tstr) HDF5.a_write(grp, _hdf5plot_datatypeid, tstr)
end end
function _hdf5plot_writetype{T<:Any}(grp, ::Type{Array{T}}) function _hdf5plot_writetype(grp, ::Type{Array{T}}) where T<:Any
tstr = HDF5PLOT_MAP_TELEM2STR[Array] #ANY tstr = HDF5PLOT_MAP_TELEM2STR[Array] #ANY
HDF5.a_write(grp, _hdf5plot_datatypeid, tstr) HDF5.a_write(grp, _hdf5plot_datatypeid, tstr)
end end
function _hdf5plot_writetype{T<:BoundingBox}(grp, ::Type{T}) function _hdf5plot_writetype(grp, ::Type{T}) where T<:BoundingBox
tstr = HDF5PLOT_MAP_TELEM2STR[BoundingBox] tstr = HDF5PLOT_MAP_TELEM2STR[BoundingBox]
HDF5.a_write(grp, _hdf5plot_datatypeid, tstr) HDF5.a_write(grp, _hdf5plot_datatypeid, tstr)
end end
@ -305,7 +305,7 @@ function _hdf5plot_gwrite(grp, k::String, v) #Default
grp[k] = v grp[k] = v
_hdf5plot_writetype(grp, k, HDF5PlotNative) _hdf5plot_writetype(grp, k, HDF5PlotNative)
end end
function _hdf5plot_gwrite{T<:Number}(grp, k::String, v::Array{T}) #Default for arrays function _hdf5plot_gwrite(grp, k::String, v::Array{T}) where T<:Number #Default for arrays
grp[k] = v grp[k] = v
_hdf5plot_writetype(grp, k, HDF5PlotNative) _hdf5plot_writetype(grp, k, HDF5PlotNative)
end end
@ -355,7 +355,7 @@ function _hdf5plot_gwrite(grp, k::String, v::Colorant)
_hdf5plot_gwrite(grp, k, ARGB{N0f8}(v)) _hdf5plot_gwrite(grp, k, ARGB{N0f8}(v))
end end
#Custom vector (when not using simple numeric type): #Custom vector (when not using simple numeric type):
function _hdf5plot_gwritearray{T}(grp, k::String, v::Array{T}) function _hdf5plot_gwritearray(grp, k::String, v::Array{T}) where T
if "annotations" == k; if "annotations" == k;
return #Hack. Does not yet support annotations. return #Hack. Does not yet support annotations.
end end
@ -380,7 +380,7 @@ function _hdf5plot_gwrite(grp, k::String, v::Extrema)
grp[k] = [v.emin, v.emax] grp[k] = [v.emin, v.emax]
_hdf5plot_writetype(grp, k, Extrema) _hdf5plot_writetype(grp, k, Extrema)
end end
function _hdf5plot_gwrite{T}(grp, k::String, v::Length{T}) function _hdf5plot_gwrite(grp, k::String, v::Length{T}) where T
grp[k] = v.value grp[k] = v.value
_hdf5plot_writetype(grp, k, [HDF5PLOT_MAP_TELEM2STR[Length], string(T)]) _hdf5plot_writetype(grp, k, [HDF5PLOT_MAP_TELEM2STR[Length], string(T)])
end end

View File

@ -131,7 +131,7 @@ end
function _inspectdr_getscale(s::Symbol, yaxis::Bool) function _inspectdr_getscale(s::Symbol, yaxis::Bool)
#TODO: Support :asinh, :sqrt #TODO: Support :asinh, :sqrt
kwargs = yaxis? (:tgtmajor=>8, :tgtminor=>2): () #More grid lines on y-axis kwargs = yaxis ? (:tgtmajor=>8, :tgtminor=>2) : () #More grid lines on y-axis
if :log2 == s if :log2 == s
return InspectDR.AxisScale(:log2; kwargs...) return InspectDR.AxisScale(:log2; kwargs...)
elseif :log10 == s elseif :log10 == s
@ -163,7 +163,7 @@ function _initialize_backend(::InspectDRBackend; kw...)
2*InspectDR.GLYPH_SQUARE.x, InspectDR.GLYPH_SQUARE.y 2*InspectDR.GLYPH_SQUARE.x, InspectDR.GLYPH_SQUARE.y
) )
type InspecDRPlotRef mutable struct InspecDRPlotRef
mplot::Union{Void, InspectDR.Multiplot} mplot::Union{Void, InspectDR.Multiplot}
gui::Union{Void, InspectDR.GtkPlot} gui::Union{Void, InspectDR.GtkPlot}
end end
@ -172,7 +172,7 @@ function _initialize_backend(::InspectDRBackend; kw...)
_inspectdr_getmplot(r::InspecDRPlotRef) = r.mplot _inspectdr_getmplot(r::InspecDRPlotRef) = r.mplot
_inspectdr_getgui(::Any) = nothing _inspectdr_getgui(::Any) = nothing
_inspectdr_getgui(gplot::InspectDR.GtkPlot) = (gplot.destroyed? nothing: gplot) _inspectdr_getgui(gplot::InspectDR.GtkPlot) = (gplot.destroyed ? nothing : gplot)
_inspectdr_getgui(r::InspecDRPlotRef) = _inspectdr_getgui(r.gui) _inspectdr_getgui(r::InspecDRPlotRef) = _inspectdr_getgui(r.gui)
end end
end end
@ -235,7 +235,7 @@ function _series_added(plt::Plot{InspectDRBackend}, series::Series)
#Don't do anything without a "subplot" object: Will process later. #Don't do anything without a "subplot" object: Will process later.
if nothing == plot; return; end if nothing == plot; return; end
_vectorize(v) = isa(v, Vector)? v: collect(v) #InspectDR only supports vectors _vectorize(v) = isa(v, Vector) ? v : collect(v) #InspectDR only supports vectors
x = _vectorize(series[:x]); y = _vectorize(series[:y]) x = _vectorize(series[:x]); y = _vectorize(series[:y])
#No support for polar grid... but can still perform polar transformation: #No support for polar grid... but can still perform polar transformation:
@ -278,7 +278,7 @@ For st in :shape:
end end
end end
i = (nmax >= 2? div(nmax, 2): nmax) #Must pick one set of colors for legend i = (nmax >= 2 ? div(nmax, 2) : nmax) #Must pick one set of colors for legend
if i > 1 #Add dummy waveform for legend entry: if i > 1 #Add dummy waveform for legend entry:
linewidth = series[:linewidth] linewidth = series[:linewidth]
linecolor = _inspectdr_mapcolor(_cycle(series[:linecolor], i)) linecolor = _inspectdr_mapcolor(_cycle(series[:linecolor], i))
@ -296,7 +296,7 @@ For st in :shape:
#NOTE: In Plots.jl, :scatter plots have 0-linewidths (I think). #NOTE: In Plots.jl, :scatter plots have 0-linewidths (I think).
linewidth = series[:linewidth] linewidth = series[:linewidth]
#More efficient & allows some support for markerstrokewidth: #More efficient & allows some support for markerstrokewidth:
_style = (0==linewidth? :none: series[:linestyle]) _style = (0==linewidth ? :none : series[:linestyle])
wfrm = InspectDR.add(plot, x, y, id=series[:label]) wfrm = InspectDR.add(plot, x, y, id=series[:label])
wfrm.line = InspectDR.line( wfrm.line = InspectDR.line(
style = _style, style = _style,

View File

@ -122,7 +122,7 @@ const _plotly_legend_pos = KW(
) )
plotly_legend_pos(pos::Symbol) = get(_plotly_legend_pos, pos, [1.,1.]) plotly_legend_pos(pos::Symbol) = get(_plotly_legend_pos, pos, [1.,1.])
plotly_legend_pos{S<:Real, T<:Real}(v::Tuple{S,T}) = v plotly_legend_pos(v::Tuple{S,T}) where {S<:Real, T<:Real} = v
function plotly_font(font::Font, color = font.color) function plotly_font(font::Font, color = font.color)
KW( KW(
@ -441,7 +441,7 @@ end
plotly_data(v) = collect(v) plotly_data(v) = collect(v)
plotly_data(surf::Surface) = surf.surf plotly_data(surf::Surface) = surf.surf
plotly_data{R<:Rational}(v::AbstractArray{R}) = float(v) plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v)
plotly_surface_data(series::Series, a::AbstractVector) = a plotly_surface_data(series::Series, a::AbstractVector) = a
plotly_surface_data(series::Series, a::AbstractMatrix) = transpose_z(series, a, false) plotly_surface_data(series::Series, a::AbstractMatrix) = transpose_z(series, a, false)

View File

@ -11,7 +11,7 @@ compute_angle(v::P2) = (angle = atan2(v[2], v[1]); angle < 0 ? 2π - angle : ang
# ------------------------------------------------------------- # -------------------------------------------------------------
immutable Shape struct Shape
x::Vector{Float64} x::Vector{Float64}
y::Vector{Float64} y::Vector{Float64}
# function Shape(x::AVec, y::AVec) # function Shape(x::AVec, y::AVec)
@ -246,7 +246,7 @@ end
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
type Font mutable struct Font
family::AbstractString family::AbstractString
pointsize::Int pointsize::Int
halign::Symbol halign::Symbol
@ -336,7 +336,7 @@ function scalefontsizes()
end end
"Wrap a string with font info" "Wrap a string with font info"
immutable PlotText struct PlotText
str::AbstractString str::AbstractString
font::Font font::Font
end end
@ -359,7 +359,7 @@ Base.length(t::PlotText) = length(t.str)
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
immutable Stroke struct Stroke
width width
color color
alpha alpha
@ -401,7 +401,7 @@ function stroke(args...; alpha = nothing)
end end
immutable Brush struct Brush
size # fillrange, markersize, or any other sizey attribute size # fillrange, markersize, or any other sizey attribute
color color
alpha alpha
@ -434,7 +434,7 @@ end
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
type SeriesAnnotations mutable struct SeriesAnnotations
strs::AbstractVector # the labels/names strs::AbstractVector # the labels/names
font::Font font::Font
baseshape::Nullable baseshape::Nullable
@ -513,7 +513,7 @@ function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
return return
end end
type EachAnn mutable struct EachAnn
anns anns
x x
y y
@ -538,12 +538,12 @@ annotations(sa::SeriesAnnotations) = sa
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
"type which represents z-values for colors and sizes (and anything else that might come up)" "type which represents z-values for colors and sizes (and anything else that might come up)"
immutable ZValues struct ZValues
values::Vector{Float64} values::Vector{Float64}
zrange::Tuple{Float64,Float64} zrange::Tuple{Float64,Float64}
end end
function zvalues{T<:Real}(values::AVec{T}, zrange::Tuple{T,T} = (ignorenan_minimum(values), ignorenan_maximum(values))) function zvalues(values::AVec{T}, zrange::Tuple{T,T} = (ignorenan_minimum(values), ignorenan_maximum(values))) where T<:Real
ZValues(collect(float(values)), map(Float64, zrange)) ZValues(collect(float(values)), map(Float64, zrange))
end end
@ -552,7 +552,7 @@ end
abstract type AbstractSurface end abstract type AbstractSurface end
"represents a contour or surface mesh" "represents a contour or surface mesh"
immutable Surface{M<:AMat} <: AbstractSurface struct Surface{M<:AMat} <: AbstractSurface
surf::M surf::M
end end
@ -564,7 +564,7 @@ for f in (:length, :size)
@eval Base.$f(surf::Surface, args...) = $f(surf.surf, args...) @eval Base.$f(surf::Surface, args...) = $f(surf.surf, args...)
end end
Base.copy(surf::Surface) = Surface(copy(surf.surf)) Base.copy(surf::Surface) = Surface(copy(surf.surf))
Base.eltype{T}(surf::Surface{T}) = eltype(T) Base.eltype(surf::Surface{T}) where {T} = eltype(T)
function expand_extrema!(a::Axis, surf::Surface) function expand_extrema!(a::Axis, surf::Surface)
ex = a[:extrema] ex = a[:extrema]
@ -575,7 +575,7 @@ function expand_extrema!(a::Axis, surf::Surface)
end end
"For the case of representing a surface as a function of x/y... can possibly avoid allocations." "For the case of representing a surface as a function of x/y... can possibly avoid allocations."
immutable SurfaceFunction <: AbstractSurface struct SurfaceFunction <: AbstractSurface
f::Function f::Function
end end
@ -585,19 +585,19 @@ end
# # I don't want to clash with ValidatedNumerics, but this would be nice: # # I don't want to clash with ValidatedNumerics, but this would be nice:
# ..(a::T, b::T) = (a,b) # ..(a::T, b::T) = (a,b)
immutable Volume{T} struct Volume{T}
v::Array{T,3} v::Array{T,3}
x_extents::Tuple{T,T} x_extents::Tuple{T,T}
y_extents::Tuple{T,T} y_extents::Tuple{T,T}
z_extents::Tuple{T,T} z_extents::Tuple{T,T}
end end
default_extents{T}(::Type{T}) = (zero(T), one(T)) default_extents(::Type{T}) where {T} = (zero(T), one(T))
function Volume{T}(v::Array{T,3}, function Volume(v::Array{T,3},
x_extents = default_extents(T), x_extents = default_extents(T),
y_extents = default_extents(T), y_extents = default_extents(T),
z_extents = default_extents(T)) z_extents = default_extents(T)) where T
Volume(v, x_extents, y_extents, z_extents) Volume(v, x_extents, y_extents, z_extents)
end end
@ -605,13 +605,13 @@ Base.Array(vol::Volume) = vol.v
for f in (:length, :size) for f in (:length, :size)
@eval Base.$f(vol::Volume, args...) = $f(vol.v, args...) @eval Base.$f(vol::Volume, args...) = $f(vol.v, args...)
end end
Base.copy{T}(vol::Volume{T}) = Volume{T}(copy(vol.v), vol.x_extents, vol.y_extents, vol.z_extents) Base.copy(vol::Volume{T}) where {T} = Volume{T}(copy(vol.v), vol.x_extents, vol.y_extents, vol.z_extents)
Base.eltype{T}(vol::Volume{T}) = T Base.eltype(vol::Volume{T}) where {T} = T
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# style is :open or :closed (for now) # style is :open or :closed (for now)
immutable Arrow struct Arrow
style::Symbol style::Symbol
side::Symbol # :head (default), :tail, or :both side::Symbol # :head (default), :tail, or :both
headlength::Float64 headlength::Float64
@ -673,14 +673,14 @@ end
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
"Represents data values with formatting that should apply to the tick labels." "Represents data values with formatting that should apply to the tick labels."
immutable Formatted{T} struct Formatted{T}
data::T data::T
formatter::Function formatter::Function
end end
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
"create a BezierCurve for plotting" "create a BezierCurve for plotting"
type BezierCurve{T <: FixedSizeArrays.Vec} mutable struct BezierCurve{T <: FixedSizeArrays.Vec}
control_points::Vector{T} control_points::Vector{T}
end end

View File

@ -558,7 +558,7 @@ function createGadflyAnnotationObject(x, y, txt::PlotText)
)) ))
end end
function _add_annotations{X,Y,V}(plt::Plot{GadflyBackend}, anns::AVec{Tuple{X,Y,V}}) function _add_annotations(plt::Plot{GadflyBackend}, anns::AVec{Tuple{X,Y,V}}) where {X,Y,V}
for ann in anns for ann in anns
push!(plt.o.guides, createGadflyAnnotationObject(ann...)) push!(plt.o.guides, createGadflyAnnotationObject(ann...))
end end
@ -614,7 +614,7 @@ function getxy(plt::Plot{GadflyBackend}, i::Integer)
mapping[:x], mapping[:y] mapping[:x], mapping[:y]
end end
function setxy!{X,Y}(plt::Plot{GadflyBackend}, xy::Tuple{X,Y}, i::Integer) function setxy!(plt::Plot{GadflyBackend}, xy::Tuple{X,Y}, i::Integer) where {X,Y}
for mapping in getGadflyMappings(plt, i) for mapping in getGadflyMappings(plt, i)
mapping[:x], mapping[:y] = xy mapping[:x], mapping[:y] = xy
end end
@ -677,7 +677,7 @@ setGadflyDisplaySize(plt::Plot) = setGadflyDisplaySize(plt.attr[:size]...)
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
function doshow{P<:Union{GadflyBackend,ImmerseBackend}}(io::IO, func, plt::AbstractPlot{P}) function doshow(io::IO, func, plt::AbstractPlot{P}) where P<:Union{GadflyBackend,ImmerseBackend}
gplt = getGadflyContext(plt) gplt = getGadflyContext(plt)
setGadflyDisplaySize(plt) setGadflyDisplaySize(plt)
Gadfly.draw(func(io, Compose.default_graphic_width, Compose.default_graphic_height), gplt) Gadfly.draw(func(io, Compose.default_graphic_width, Compose.default_graphic_height), gplt)
@ -692,7 +692,7 @@ getGadflyWriteFunc(::MIME"application/x-tex") = Gadfly.PGF
getGadflyWriteFunc(m::MIME) = error("Unsupported in Gadfly/Immerse: ", m) getGadflyWriteFunc(m::MIME) = error("Unsupported in Gadfly/Immerse: ", m)
for mime in (MIME"image/png", MIME"image/svg+xml", MIME"application/pdf", MIME"application/postscript", MIME"application/x-tex") for mime in (MIME"image/png", MIME"image/svg+xml", MIME"application/pdf", MIME"application/postscript", MIME"application/x-tex")
@eval function Base.show{P<:Union{GadflyBackend,ImmerseBackend}}(io::IO, ::$mime, plt::AbstractPlot{P}) @eval function Base.show(io::IO, ::$mime, plt::AbstractPlot{P}) where P<:Union{GadflyBackend,ImmerseBackend}
func = getGadflyWriteFunc($mime()) func = getGadflyWriteFunc($mime())
doshow(io, func, plt) doshow(io, func, plt)
end end

View File

@ -2,7 +2,7 @@
# Geometry which displays arbitrary shapes at given (x, y) positions. # Geometry which displays arbitrary shapes at given (x, y) positions.
# note: vertices is a list of shapes # note: vertices is a list of shapes
immutable ShapeGeometry <: Gadfly.GeometryElement struct ShapeGeometry <: Gadfly.GeometryElement
vertices::AbstractVector #{Tuple{Float64,Float64}} vertices::AbstractVector #{Tuple{Float64,Float64}}
tag::Symbol tag::Symbol

View File

@ -61,7 +61,7 @@ end
# ---------------------------------------------------------------- # ----------------------------------------------------------------
function _add_annotations{X,Y,V}(plt::Plot{ImmerseBackend}, anns::AVec{Tuple{X,Y,V}}) function _add_annotations(plt::Plot{ImmerseBackend}, anns::AVec{Tuple{X,Y,V}}) where {X,Y,V}
for ann in anns for ann in anns
push!(getGadflyContext(plt).guides, createGadflyAnnotationObject(ann...)) push!(getGadflyContext(plt).guides, createGadflyAnnotationObject(ann...))
end end
@ -76,7 +76,7 @@ function getxy(plt::Plot{ImmerseBackend}, i::Integer)
mapping[:x], mapping[:y] mapping[:x], mapping[:y]
end end
function setxy!{X,Y}(plt::Plot{ImmerseBackend}, xy::Tuple{X,Y}, i::Integer) function setxy!(plt::Plot{ImmerseBackend}, xy::Tuple{X,Y}, i::Integer) where {X,Y}
for mapping in getGadflyMappings(plt, i) for mapping in getGadflyMappings(plt, i)
mapping[:x], mapping[:y] = xy mapping[:x], mapping[:y] = xy
end end

View File

@ -218,7 +218,7 @@ function createQwtAnnotation(plt::Plot, x, y, val::AbstractString)
marker[:attach](plt.o.widget) marker[:attach](plt.o.widget)
end end
function _add_annotations{X,Y,V}(plt::Plot{QwtBackend}, anns::AVec{Tuple{X,Y,V}}) function _add_annotations(plt::Plot{QwtBackend}, anns::AVec{Tuple{X,Y,V}}) where {X,Y,V}
for ann in anns for ann in anns
createQwtAnnotation(plt, ann...) createQwtAnnotation(plt, ann...)
end end
@ -233,7 +233,7 @@ function getxy(plt::Plot{QwtBackend}, i::Int)
series.x, series.y series.x, series.y
end end
function setxy!{X,Y}(plt::Plot{QwtBackend}, xy::Tuple{X,Y}, i::Integer) function setxy!(plt::Plot{QwtBackend}, xy::Tuple{X,Y}, i::Integer) where {X,Y}
series = plt.o.lines[i] series = plt.o.lines[i]
series.x, series.y = xy series.x, series.y = xy
plt plt

View File

@ -217,7 +217,7 @@ function createWinstonAnnotationObject(plt::Plot{WinstonBackend}, x, y, val::Abs
Winston.text(x, y, val) Winston.text(x, y, val)
end end
function _add_annotations{X,Y,V}(plt::Plot{WinstonBackend}, anns::AVec{Tuple{X,Y,V}}) function _add_annotations(plt::Plot{WinstonBackend}, anns::AVec{Tuple{X,Y,V}}) where {X,Y,V}
for ann in anns for ann in anns
createWinstonAnnotationObject(plt, ann...) createWinstonAnnotationObject(plt, ann...)
end end

View File

@ -34,9 +34,9 @@ getColorVector(scheme::ColorScheme) = [getColor(scheme)]
colorscheme(scheme::ColorScheme) = scheme colorscheme(scheme::ColorScheme) = scheme
colorscheme(s::AbstractString; kw...) = colorscheme(Symbol(s); kw...) colorscheme(s::AbstractString; kw...) = colorscheme(Symbol(s); kw...)
colorscheme(s::Symbol; kw...) = haskey(_gradients, s) ? ColorGradient(s; kw...) : ColorWrapper(convertColor(s); kw...) colorscheme(s::Symbol; kw...) = haskey(_gradients, s) ? ColorGradient(s; kw...) : ColorWrapper(convertColor(s); kw...)
colorscheme{T<:Real}(s::Symbol, vals::AVec{T}; kw...) = ColorGradient(s, vals; kw...) colorscheme(s::Symbol, vals::AVec{T}; kw...) where {T<:Real} = ColorGradient(s, vals; kw...)
colorscheme(cs::AVec, vs::AVec; kw...) = ColorGradient(cs, vs; kw...) colorscheme(cs::AVec, vs::AVec; kw...) = ColorGradient(cs, vs; kw...)
colorscheme{T<:Colorant}(cs::AVec{T}; kw...) = ColorGradient(cs; kw...) colorscheme(cs::AVec{T}; kw...) where {T<:Colorant} = ColorGradient(cs; kw...)
colorscheme(f::Function; kw...) = ColorFunction(f; kw...) colorscheme(f::Function; kw...) = ColorFunction(f; kw...)
colorscheme(v::AVec; kw...) = ColorVector(v; kw...) colorscheme(v::AVec; kw...) = ColorVector(v; kw...)
colorscheme(m::AMat; kw...) = size(m,1) == 1 ? map(c->colorscheme(c; kw...), m) : [colorscheme(m[:,i]; kw...) for i in 1:size(m,2)]' colorscheme(m::AMat; kw...) = size(m,1) == 1 ? map(c->colorscheme(c; kw...), m) : [colorscheme(m[:,i]; kw...) for i in 1:size(m,2)]'
@ -98,7 +98,7 @@ const _gradients = KW(
:lighttest => map(c -> lighten(c, 0.3), _testColors), :lighttest => map(c -> lighten(c, 0.3), _testColors),
) )
function register_gradient_colors{C<:Colorant}(name::Symbol, colors::AVec{C}) function register_gradient_colors(name::Symbol, colors::AVec{C}) where C<:Colorant
_gradients[name] = colors _gradients[name] = colors
end end
@ -109,11 +109,11 @@ default_gradient() = ColorGradient(:inferno)
# -------------------------------------------------------------- # --------------------------------------------------------------
"Continuous gradient between values. Wraps a list of bounding colors and the values they represent." "Continuous gradient between values. Wraps a list of bounding colors and the values they represent."
immutable ColorGradient <: ColorScheme struct ColorGradient <: ColorScheme
colors::Vector colors::Vector
values::Vector values::Vector
function ColorGradient{S<:Real}(cs::AVec, vals::AVec{S} = linspace(0, 1, length(cs)); alpha = nothing) function ColorGradient(cs::AVec, vals::AVec{S} = linspace(0, 1, 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
@ -138,7 +138,7 @@ Base.getindex(cs::ColorGradient, z::Number) = getColorZ(cs, z)
# create a gradient from a symbol (blues, reds, etc) and vector of boundary values # create a gradient from a symbol (blues, reds, etc) and vector of boundary values
function ColorGradient{T<:Real}(s::Symbol, vals::AVec{T} = 0:0; kw...) 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
@ -208,7 +208,7 @@ end
# -------------------------------------------------------------- # --------------------------------------------------------------
"Wraps a function, taking an index and returning a Colorant" "Wraps a function, taking an index and returning a Colorant"
immutable ColorFunction <: ColorScheme struct ColorFunction <: ColorScheme
f::Function f::Function
end end
@ -217,7 +217,7 @@ getColor(scheme::ColorFunction, idx::Int) = scheme.f(idx)
# -------------------------------------------------------------- # --------------------------------------------------------------
"Wraps a function, taking an z-value and returning a Colorant" "Wraps a function, taking an z-value and returning a Colorant"
immutable ColorZFunction <: ColorScheme struct ColorZFunction <: ColorScheme
f::Function f::Function
end end
@ -226,7 +226,7 @@ getColorZ(scheme::ColorZFunction, z::Real) = scheme.f(z)
# -------------------------------------------------------------- # --------------------------------------------------------------
"Wraps a vector of colors... may be vector of Symbol/String/Colorant" "Wraps a vector of colors... may be vector of Symbol/String/Colorant"
immutable ColorVector <: ColorScheme struct ColorVector <: ColorScheme
v::Vector{Colorant} v::Vector{Colorant}
ColorVector(v::AVec; alpha = nothing) = new(convertColor(v,alpha)) ColorVector(v::AVec; alpha = nothing) = new(convertColor(v,alpha))
end end
@ -238,7 +238,7 @@ getColorVector(scheme::ColorVector) = scheme.v
# -------------------------------------------------------------- # --------------------------------------------------------------
"Wraps a single color" "Wraps a single color"
immutable ColorWrapper <: ColorScheme struct ColorWrapper <: ColorScheme
c::RGBA c::RGBA
ColorWrapper(c::Colorant; alpha = nothing) = new(convertColor(c, alpha)) ColorWrapper(c::Colorant; alpha = nothing) = new(convertColor(c, alpha))
end end
@ -347,8 +347,8 @@ function get_color_palette(palette, bgcolor::Union{Colorant,ColorWrapper}, numco
RGBA[getColorZ(grad, z) for z in zrng] RGBA[getColorZ(grad, z) for z in zrng]
end end
function get_color_palette{C<:Colorant}(palette::Vector{C}, function get_color_palette(palette::Vector{C},
bgcolor::Union{Colorant,ColorWrapper}, numcolors::Integer) bgcolor::Union{Colorant,ColorWrapper}, numcolors::Integer) where C<:Colorant
palette palette
end end

View File

@ -5,21 +5,21 @@
# This should cut down on boilerplate code and allow more focused dispatch on type # This should cut down on boilerplate code and allow more focused dispatch on type
# note: returns meta information... mainly for use with automatic labeling from DataFrames for now # note: returns meta information... mainly for use with automatic labeling from DataFrames for now
const FuncOrFuncs = @compat(Union{Function, AVec{Function}}) 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::@compat(Void), d::KW) = Any[nothing], nothing convertToAnyVector(v::Void, 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
# numeric vector # numeric vector
convertToAnyVector{T<:Number}(v::AVec{T}, d::KW) = Any[v], nothing convertToAnyVector(v::AVec{T}, d::KW) where {T<:Number} = Any[v], nothing
# string vector # string vector
convertToAnyVector{T<:@compat(AbstractString)}(v::AVec{T}, d::KW) = Any[v], nothing convertToAnyVector(v::AVec{T}, d::KW) where {T<:AbstractString} = Any[v], nothing
function convertToAnyVector(v::AMat, d::KW) function convertToAnyVector(v::AMat, d::KW)
if all3D(d) if all3D(d)
@ -39,7 +39,7 @@ convertToAnyVector(s::Surface, d::KW) = Any[s], 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)

View File

@ -1,7 +1,7 @@
""" """
Holds all data needed for a documentation example... header, description, and plotting expression (Expr) Holds all data needed for a documentation example... header, description, and plotting expression (Expr)
""" """
type PlotExample mutable struct PlotExample
header::AbstractString header::AbstractString
desc::AbstractString desc::AbstractString
exprs::Vector{Expr} exprs::Vector{Expr}

View File

@ -13,7 +13,7 @@ Base.zero(::Type{typeof(mm)}) = 0mm
Base.one(::Type{typeof(mm)}) = 1mm Base.one(::Type{typeof(mm)}) = 1mm
Base.typemin(::typeof(mm)) = -Inf*mm Base.typemin(::typeof(mm)) = -Inf*mm
Base.typemax(::typeof(mm)) = Inf*mm Base.typemax(::typeof(mm)) = Inf*mm
Base.convert{F<:AbstractFloat}(::Type{F}, l::AbsoluteLength) = convert(F, l.value) Base.convert(::Type{F}, l::AbsoluteLength) where {F<:AbstractFloat} = convert(F, l.value)
# TODO: these are unintuitive and may cause tricky bugs # TODO: these are unintuitive and may cause tricky bugs
# Base.:+(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * (1 + m2.value)) # Base.:+(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * (1 + m2.value))
@ -95,7 +95,7 @@ end
# ----------------------------------------------------------- # -----------------------------------------------------------
# points combined by x/y, pct, and length # points combined by x/y, pct, and length
type MixedMeasures mutable struct MixedMeasures
xy::Float64 xy::Float64
pct::Float64 pct::Float64
len::AbsoluteLength len::AbsoluteLength
@ -216,7 +216,7 @@ bottompad(layout::AbstractLayout) = 0mm
# RootLayout # RootLayout
# this is the parent of the top-level layout # this is the parent of the top-level layout
immutable RootLayout <: AbstractLayout end struct RootLayout <: AbstractLayout end
Base.parent(::RootLayout) = nothing Base.parent(::RootLayout) = nothing
parent_bbox(::RootLayout) = defaultbox parent_bbox(::RootLayout) = defaultbox
@ -226,7 +226,7 @@ bbox(::RootLayout) = defaultbox
# EmptyLayout # EmptyLayout
# contains blank space # contains blank space
type EmptyLayout <: AbstractLayout mutable struct EmptyLayout <: AbstractLayout
parent::AbstractLayout parent::AbstractLayout
bbox::BoundingBox bbox::BoundingBox
attr::KW # store label, width, and height for initialization attr::KW # store label, width, and height for initialization
@ -244,7 +244,7 @@ _update_min_padding!(layout::EmptyLayout) = nothing
# GridLayout # GridLayout
# nested, gridded layout with optional size percentages # nested, gridded layout with optional size percentages
type GridLayout <: AbstractLayout mutable struct GridLayout <: AbstractLayout
parent::AbstractLayout parent::AbstractLayout
minpad::Tuple # leftpad, toppad, rightpad, bottompad minpad::Tuple # leftpad, toppad, rightpad, bottompad
bbox::BoundingBox bbox::BoundingBox
@ -481,12 +481,12 @@ function layout_args(n::Integer)
GridLayout(nr, nc), n GridLayout(nr, nc), n
end end
function layout_args{I<:Integer}(sztup::NTuple{2,I}) function layout_args(sztup::NTuple{2,I}) where I<:Integer
nr, nc = sztup nr, nc = sztup
GridLayout(nr, nc), nr*nc GridLayout(nr, nc), nr*nc
end end
function layout_args{I<:Integer}(sztup::NTuple{3,I}) function layout_args(sztup::NTuple{3,I}) where I<:Integer
n, nr, nc = sztup n, nr, nc = sztup
nr, nc = compute_gridsize(n, nr, nc) nr, nc = compute_gridsize(n, nr, nc)
GridLayout(nr, nc), n GridLayout(nr, nc), n

View File

@ -193,7 +193,7 @@ function Base.show(io::IO, ::MIME"text/html", plt::Plot)
end end
end end
function _show{B}(io::IO, m, plt::Plot{B}) function _show(io::IO, m, plt::Plot{B}) where B
# Base.show_backtrace(STDOUT, backtrace()) # Base.show_backtrace(STDOUT, backtrace())
warn("_show is not defined for this backend. m=", string(m)) warn("_show is not defined for this backend. m=", string(m))
end end
@ -203,7 +203,7 @@ end
# for writing to io streams... first prepare, then callback # for writing to io streams... first prepare, then callback
for mime in keys(_mimeformats) for mime in keys(_mimeformats)
@eval function Base.show{B}(io::IO, m::MIME{Symbol($mime)}, plt::Plot{B}) @eval function Base.show(io::IO, m::MIME{Symbol($mime)}, plt::Plot{B}) where B
prepare_output(plt) prepare_output(plt)
_show(io, m, plt) _show(io, m, plt)
end end
@ -293,7 +293,7 @@ end
Media.media(Plot, Media.Plot) Media.media(Plot, Media.Plot)
_show{B}(io::IO, m::MIME"text/plain", plt::Plot{B}) = print(io, "Plot{$B}()") _show(io::IO, m::MIME"text/plain", plt::Plot{B}) where {B} = print(io, "Plot{$B}()")
function Juno.render(e::Juno.Editor, plt::Plot) function Juno.render(e::Juno.Editor, plt::Plot)
Juno.render(e, nothing) Juno.render(e, nothing)

View File

@ -301,7 +301,7 @@ end
# getting ready to add the series... last update to subplot from anything # getting ready to add the series... last update to subplot from anything
# that might have been added during series recipes # that might have been added during series recipes
function _prepare_subplot{T}(plt::Plot{T}, d::KW) function _prepare_subplot(plt::Plot{T}, d::KW) where T
st::Symbol = d[:seriestype] st::Symbol = d[:seriestype]
sp::Subplot{T} = d[:subplot] sp::Subplot{T} = d[:subplot]
sp_idx = get_subplot_index(plt, sp) sp_idx = get_subplot_index(plt, sp)

View File

@ -1,5 +1,5 @@
type CurrentPlot mutable struct CurrentPlot
nullableplot::Nullable{AbstractPlot} nullableplot::Nullable{AbstractPlot}
end end
const CURRENT_PLOT = CurrentPlot(Nullable{AbstractPlot}()) const CURRENT_PLOT = CurrentPlot(Nullable{AbstractPlot}())

View File

@ -47,7 +47,7 @@ end
num_series(x::AMat) = size(x,2) num_series(x::AMat) = size(x,2)
num_series(x) = 1 num_series(x) = 1
RecipesBase.apply_recipe{T}(d::KW, ::Type{T}, plt::AbstractPlot) = throw(MethodError("Unmatched plot recipe: $T")) RecipesBase.apply_recipe(d::KW, ::Type{T}, plt::AbstractPlot) where {T} = throw(MethodError("Unmatched plot recipe: $T"))
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -343,9 +343,9 @@ _bin_centers(v::AVec) = (v[1:end-1] + v[2:end]) / 2
_is_positive(x) = (x > 0) && !(x 0) _is_positive(x) = (x > 0) && !(x 0)
_positive_else_nan{T}(::Type{T}, x::Real) = _is_positive(x) ? T(x) : T(NaN) _positive_else_nan(::Type{T}, x::Real) where {T} = _is_positive(x) ? T(x) : T(NaN)
function _scale_adjusted_values{T<:AbstractFloat}(::Type{T}, V::AbstractVector, scale::Symbol) function _scale_adjusted_values(::Type{T}, V::AbstractVector, scale::Symbol) where T<:AbstractFloat
if scale in _logScales if scale in _logScales
[_positive_else_nan(T, x) for x in V] [_positive_else_nan(T, x) for x in V]
else else
@ -354,7 +354,7 @@ function _scale_adjusted_values{T<:AbstractFloat}(::Type{T}, V::AbstractVector,
end end
function _binbarlike_baseline{T<:Real}(min_value::T, scale::Symbol) function _binbarlike_baseline(min_value::T, scale::Symbol) where T<:Real
if (scale in _logScales) if (scale in _logScales)
!isnan(min_value) ? min_value / T(_logScaleBases[scale]^log10(2)) : T(1E-3) !isnan(min_value) ? min_value / T(_logScaleBases[scale]^log10(2)) : T(1E-3)
else else
@ -363,7 +363,7 @@ function _binbarlike_baseline{T<:Real}(min_value::T, scale::Symbol)
end end
function _preprocess_binbarlike_weights{T<:AbstractFloat}(::Type{T}, w, wscale::Symbol) function _preprocess_binbarlike_weights(::Type{T}, w, wscale::Symbol) where T<:AbstractFloat
w_adj = _scale_adjusted_values(T, w, wscale) w_adj = _scale_adjusted_values(T, w, wscale)
w_min = ignorenan_minimum(w_adj) w_min = ignorenan_minimum(w_adj)
w_max = ignorenan_maximum(w_adj) w_max = ignorenan_maximum(w_adj)
@ -499,7 +499,7 @@ 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{N}(vs::NTuple{N,AbstractVector}, dim::Integer; mode::Symbol = :auto) 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, NaNMath.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) = ignorenan_maximum(v) - ignorenan_minimum(v)
@ -533,20 +533,20 @@ function _auto_binning_nbins{N}(vs::NTuple{N,AbstractVector}, dim::Integer; mode
end end
end end
_hist_edge{N}(vs::NTuple{N,AbstractVector}, dim::Integer, binning::Integer) = StatsBase.histrange(vs[dim], binning, :left) _hist_edge(vs::NTuple{N,AbstractVector}, dim::Integer, binning::Integer) where {N} = StatsBase.histrange(vs[dim], binning, :left)
_hist_edge{N}(vs::NTuple{N,AbstractVector}, dim::Integer, binning::Symbol) = _hist_edge(vs, dim, _auto_binning_nbins(vs, dim, mode = binning)) _hist_edge(vs::NTuple{N,AbstractVector}, dim::Integer, binning::Symbol) where {N} = _hist_edge(vs, dim, _auto_binning_nbins(vs, dim, mode = binning))
_hist_edge{N}(vs::NTuple{N,AbstractVector}, dim::Integer, binning::AbstractVector) = binning _hist_edge(vs::NTuple{N,AbstractVector}, dim::Integer, binning::AbstractVector) where {N} = binning
_hist_edges{N}(vs::NTuple{N,AbstractVector}, binning::NTuple{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{N}(vs::NTuple{N,AbstractVector}, binning::Union{Integer, Symbol, AbstractVector}) = _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
function _make_hist{N}(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing) function _make_hist(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing) where N
edges = _hist_edges(vs, binning) edges = _hist_edges(vs, binning)
h = float( weights == nothing ? h = float( weights == nothing ?
StatsBase.fit(StatsBase.Histogram, vs, edges, closed = :left) : StatsBase.fit(StatsBase.Histogram, vs, edges, closed = :left) :
@ -590,7 +590,7 @@ end
@deps scatterhist scatterbins @deps scatterhist scatterbins
@recipe function f{T, E}(h::StatsBase.Histogram{T, 1, E}) @recipe function f(h::StatsBase.Histogram{T, 1, E}) where {T, E}
seriestype --> :barbins seriestype --> :barbins
st_map = Dict( st_map = Dict(
@ -611,7 +611,7 @@ end
end end
@recipe function f{H <: StatsBase.Histogram}(hv::AbstractVector{H}) @recipe function f(hv::AbstractVector{H}) where H <: StatsBase.Histogram
for h in hv for h in hv
@series begin @series begin
h h
@ -658,7 +658,7 @@ end
@deps histogram2d bins2d @deps histogram2d bins2d
@recipe function f{T, E}(h::StatsBase.Histogram{T, 2, E}) @recipe function f(h::StatsBase.Histogram{T, 2, E}) where {T, E}
seriestype --> :bins2d seriestype --> :bins2d
(h.edges[1], h.edges[2], Surface(h.weights)) (h.edges[1], h.edges[2], Surface(h.weights))
end end
@ -855,7 +855,7 @@ end
# TODO: move OHLC to PlotRecipes finance.jl # TODO: move OHLC to PlotRecipes finance.jl
"Represent Open High Low Close data (used in finance)" "Represent Open High Low Close data (used in finance)"
type OHLC{T<:Real} mutable struct OHLC{T<:Real}
open::T open::T
high::T high::T
low::T low::T
@ -894,10 +894,10 @@ end
# to squash ambiguity warnings... # to squash ambiguity warnings...
@recipe f(x::AVec{Function}, v::AVec{OHLC}) = error() @recipe f(x::AVec{Function}, v::AVec{OHLC}) = error()
@recipe f{R1<:Number,R2<:Number,R3<:Number,R4<:Number}(x::AVec{Function}, v::AVec{Tuple{R1,R2,R3,R4}}) = error() @recipe f(x::AVec{Function}, v::AVec{Tuple{R1,R2,R3,R4}}) where {R1<:Number,R2<:Number,R3<:Number,R4<:Number} = error()
# this must be OHLC? # this must be OHLC?
@recipe f{R1<:Number,R2<:Number,R3<:Number,R4<:Number}(x::AVec, ohlc::AVec{Tuple{R1,R2,R3,R4}}) = x, OHLC[OHLC(t...) for t in ohlc] @recipe f(x::AVec, ohlc::AVec{Tuple{R1,R2,R3,R4}}) where {R1<:Number,R2<:Number,R3<:Number,R4<:Number} = x, OHLC[OHLC(t...) for t in ohlc]
@recipe function f(x::AVec, v::AVec{OHLC}) @recipe function f(x::AVec, v::AVec{OHLC})
seriestype := :path seriestype := :path
@ -987,7 +987,7 @@ datetimeformatter(dt) = string(DateTime(Dates.UTM(dt)))
# ------------------------------------------------- # -------------------------------------------------
# Complex Numbers # Complex Numbers
@recipe function f{T<:Number}(A::Array{Complex{T}}) @recipe function f(A::Array{Complex{T}}) where T<:Number
xguide --> "Re(x)" xguide --> "Re(x)"
yguide --> "Im(x)" yguide --> "Im(x)"
real.(A), imag.(A) real.(A), imag.(A)
@ -996,7 +996,7 @@ end
# Splits a complex matrix to its real and complex parts # Splits a complex matrix to its real and complex parts
# Reals defaults solid, imaginary defaults dashed # Reals defaults solid, imaginary defaults dashed
# Label defaults are changed to match the real-imaginary reference / indexing # Label defaults are changed to match the real-imaginary reference / indexing
@recipe function f{T<:Real,T2}(x::AbstractArray{T},y::Array{Complex{T2}}) @recipe function f(x::AbstractArray{T},y::Array{Complex{T2}}) where {T<:Real,T2}
ylabel --> "Re(y)" ylabel --> "Re(y)"
zlabel --> "Im(y)" zlabel --> "Im(y)"
x,real.(y),imag.(y) x,real.(y),imag.(y)

View File

@ -20,10 +20,10 @@ convertToAnyVector(v::Void, d::KW) = Any[nothing], nothing
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
# numeric vector # numeric vector
convertToAnyVector{T<:Number}(v::AVec{T}, d::KW) = Any[v], nothing convertToAnyVector(v::AVec{T}, d::KW) where {T<:Number} = Any[v], nothing
# string vector # string vector
convertToAnyVector{T<:AbstractString}(v::AVec{T}, d::KW) = Any[v], nothing convertToAnyVector(v::AVec{T}, d::KW) where {T<:AbstractString} = Any[v], nothing
function convertToAnyVector(v::AMat, d::KW) function convertToAnyVector(v::AMat, d::KW)
if all3D(d) if all3D(d)
@ -99,8 +99,8 @@ nobigs(v) = v
end end
# not allowed # not allowed
compute_xyz{F<:Function}(x::Void, y::FuncOrFuncs{F}, z) = error("If you want to plot the function `$y`, you need to define the x values!") 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{F<:Function}(x::Void, y::Void, z::FuncOrFuncs{F}) = error("If you want to plot the function `$z`, you need to define x and y 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::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -109,7 +109,7 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
# we are going to build recipes to do the processing and splitting of the args # we are going to build recipes to do the processing and splitting of the args
# ensure we dispatch to the slicer # ensure we dispatch to the slicer
immutable SliceIt end struct SliceIt end
# the catch-all recipes # the catch-all recipes
@recipe function f(::Type{SliceIt}, x, y, z) @recipe function f(::Type{SliceIt}, x, y, z)
@ -163,10 +163,10 @@ immutable SliceIt end
end end
# this is the default "type recipe"... just pass the object through # this is the default "type recipe"... just pass the object through
@recipe f{T<:Any}(::Type{T}, v::T) = v @recipe f(::Type{T}, v::T) where {T<:Any} = v
# this should catch unhandled "series recipes" and error with a nice message # this should catch unhandled "series recipes" and error with a nice message
@recipe f{V<:Val}(::Type{V}, x, y, z) = error("The backend must not support the series type $V, and there isn't a series recipe defined.") @recipe f(::Type{V}, x, y, z) where {V<:Val} = error("The backend must not support the series type $V, and there isn't a series recipe defined.")
_apply_type_recipe(d, v) = RecipesBase.apply_recipe(d, typeof(v), v)[1].args[1] _apply_type_recipe(d, v) = RecipesBase.apply_recipe(d, typeof(v), v)[1].args[1]
@ -201,7 +201,7 @@ end
# end # end
# don't do anything for ints or floats # don't do anything for ints or floats
_apply_type_recipe{T<:Union{Integer,AbstractFloat}}(d, v::AbstractArray{T}) = v _apply_type_recipe(d, v::AbstractArray{T}) where {T<:Union{Integer,AbstractFloat}} = v
# handle "type recipes" by converting inputs, and then either re-calling or slicing # handle "type recipes" by converting inputs, and then either re-calling or slicing
@recipe function f(x, y, z) @recipe function f(x, y, z)
@ -274,7 +274,7 @@ end
@recipe f(n::Integer) = is3d(get(plotattributes,:seriestype,:path)) ? (SliceIt, n, n, n) : (SliceIt, n, n, nothing) @recipe f(n::Integer) = is3d(get(plotattributes,:seriestype,:path)) ? (SliceIt, n, n, n) : (SliceIt, n, n, nothing)
# return a surface if this is a 3d plot, otherwise let it be sliced up # return a surface if this is a 3d plot, otherwise let it be sliced up
@recipe function f{T<:Union{Integer,AbstractFloat}}(mat::AMat{T}) @recipe function f(mat::AMat{T}) where T<:Union{Integer,AbstractFloat}
if all3D(plotattributes) if all3D(plotattributes)
n,m = size(mat) n,m = size(mat)
wrap_surfaces(plotattributes) wrap_surfaces(plotattributes)
@ -285,7 +285,7 @@ end
end end
# if a matrix is wrapped by Formatted, do similar logic, but wrap data with Surface # if a matrix is wrapped by Formatted, do similar logic, but wrap data with Surface
@recipe function f{T<:AbstractMatrix}(fmt::Formatted{T}) @recipe function f(fmt::Formatted{T}) where T<:AbstractMatrix
if all3D(plotattributes) if all3D(plotattributes)
mat = fmt.data mat = fmt.data
n,m = size(mat) n,m = size(mat)
@ -297,7 +297,7 @@ end
end end
# assume this is a Volume, so construct one # assume this is a Volume, so construct one
@recipe function f{T<:Number}(vol::AbstractArray{T,3}, args...) @recipe function f(vol::AbstractArray{T,3}, args...) where T<:Number
seriestype := :volume seriestype := :volume
SliceIt, nothing, Volume(vol, args...), nothing SliceIt, nothing, Volume(vol, args...), nothing
end end
@ -305,7 +305,7 @@ end
# # images - grays # # images - grays
@recipe function f{T<:Gray}(mat::AMat{T}) @recipe function f(mat::AMat{T}) where T<:Gray
if is_seriestype_supported(:image) if is_seriestype_supported(:image)
seriestype := :image seriestype := :image
n, m = size(mat) n, m = size(mat)
@ -320,7 +320,7 @@ end
# # images - colors # # images - colors
@recipe function f{T<:Colorant}(mat::AMat{T}) @recipe function f(mat::AMat{T}) where T<:Colorant
n, m = size(mat) n, m = size(mat)
if is_seriestype_supported(:image) if is_seriestype_supported(:image)
@ -358,7 +358,7 @@ end
# function without range... use the current range of the x-axis # function without range... use the current range of the x-axis
@recipe function f{F<:Function}(f::FuncOrFuncs{F}) @recipe function f(f::FuncOrFuncs{F}) where F<:Function
plt = plotattributes[:plot_object] plt = plotattributes[:plot_object]
xmin, xmax = try xmin, xmax = try
axis_limits(plt[1][:xaxis]) axis_limits(plt[1][:xaxis])
@ -397,7 +397,7 @@ end
# # if functions come first, just swap the order (not to be confused with parametric functions... # # if functions come first, just swap the order (not to be confused with parametric functions...
# # as there would be more than one function passed in) # # as there would be more than one function passed in)
@recipe function f{F<:Function}(f::FuncOrFuncs{F}, x) @recipe function f(f::FuncOrFuncs{F}, x) where F<:Function
F2 = typeof(x) F2 = typeof(x)
@assert !(F2 <: Function || (F2 <: AbstractArray && F2.parameters[1] <: Function)) # otherwise we'd hit infinite recursion here @assert !(F2 <: Function || (F2 <: AbstractArray && F2.parameters[1] <: Function)) # otherwise we'd hit infinite recursion here
x, f x, f
@ -465,19 +465,19 @@ end
xs = adapted_grid(f, (xmin, xmax)) xs = adapted_grid(f, (xmin, xmax))
xs, f xs, f
end end
@recipe function f{F<:Function}(fs::AbstractArray{F}, xmin::Number, xmax::Number) @recipe function f(fs::AbstractArray{F}, xmin::Number, xmax::Number) where F<:Function
xs = Any[adapted_grid(f, (xmin, xmax)) for f in fs] xs = Any[adapted_grid(f, (xmin, xmax)) for f in fs]
xs, fs xs, fs
end end
@recipe f{F<:Function,G<:Function}(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, u::AVec) = mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u) @recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, u::AVec) where {F<:Function,G<:Function} = mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u)
@recipe f{F<:Function,G<:Function}(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, umin::Number, umax::Number, n = 200) = 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, linspace(umin, umax, n)
# #
# # special handling... 3D parametric function(s) # # special handling... 3D parametric function(s)
@recipe function f{F<:Function,G<:Function,H<:Function}(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, fz::FuncOrFuncs{H}, u::AVec) @recipe function f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, fz::FuncOrFuncs{H}, u::AVec) where {F<:Function,G<:Function,H<:Function}
mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u), mapFuncOrFuncs(fz, u) mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u), mapFuncOrFuncs(fz, u)
end end
@recipe function f{F<:Function,G<:Function,H<:Function}(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, fz::FuncOrFuncs{H}, umin::Number, umax::Number, numPoints = 200) @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, linspace(umin, umax, numPoints)
end end
@ -492,28 +492,28 @@ end
# #
# # (x,y) tuples # # (x,y) tuples
@recipe f{R1<:Number,R2<:Number}(xy::AVec{Tuple{R1,R2}}) = unzip(xy) @recipe f(xy::AVec{Tuple{R1,R2}}) where {R1<:Number,R2<:Number} = unzip(xy)
@recipe f{R1<:Number,R2<:Number}(xy::Tuple{R1,R2}) = [xy[1]], [xy[2]] @recipe f(xy::Tuple{R1,R2}) where {R1<:Number,R2<:Number} = [xy[1]], [xy[2]]
# #
# # (x,y,z) tuples # # (x,y,z) tuples
@recipe f{R1<:Number,R2<:Number,R3<:Number}(xyz::AVec{Tuple{R1,R2,R3}}) = unzip(xyz) @recipe f(xyz::AVec{Tuple{R1,R2,R3}}) where {R1<:Number,R2<:Number,R3<:Number} = unzip(xyz)
@recipe f{R1<:Number,R2<:Number,R3<:Number}(xyz::Tuple{R1,R2,R3}) = [xyz[1]], [xyz[2]], [xyz[3]] @recipe f(xyz::Tuple{R1,R2,R3}) where {R1<:Number,R2<:Number,R3<:Number} = [xyz[1]], [xyz[2]], [xyz[3]]
# these might be points+velocity, or OHLC or something else # these might be points+velocity, or OHLC or something else
@recipe f{R1<:Number,R2<:Number,R3<:Number,R4<:Number}(xyuv::AVec{Tuple{R1,R2,R3,R4}}) = get(plotattributes,:seriestype,:path)==:ohlc ? OHLC[OHLC(t...) for t in xyuv] : unzip(xyuv) @recipe f(xyuv::AVec{Tuple{R1,R2,R3,R4}}) where {R1<:Number,R2<:Number,R3<:Number,R4<:Number} = get(plotattributes,:seriestype,:path)==:ohlc ? OHLC[OHLC(t...) for t in xyuv] : unzip(xyuv)
@recipe f{R1<:Number,R2<:Number,R3<:Number,R4<:Number}(xyuv::Tuple{R1,R2,R3,R4}) = [xyuv[1]], [xyuv[2]], [xyuv[3]], [xyuv[4]] @recipe f(xyuv::Tuple{R1,R2,R3,R4}) where {R1<:Number,R2<:Number,R3<:Number,R4<:Number} = [xyuv[1]], [xyuv[2]], [xyuv[3]], [xyuv[4]]
# #
# # 2D FixedSizeArrays # # 2D FixedSizeArrays
@recipe f{T<:Number}(xy::AVec{FixedSizeArrays.Vec{2,T}}) = unzip(xy) @recipe f(xy::AVec{FixedSizeArrays.Vec{2,T}}) where {T<:Number} = unzip(xy)
@recipe f{T<:Number}(xy::FixedSizeArrays.Vec{2,T}) = [xy[1]], [xy[2]] @recipe f(xy::FixedSizeArrays.Vec{2,T}) where {T<:Number} = [xy[1]], [xy[2]]
# #
# # 3D FixedSizeArrays # # 3D FixedSizeArrays
@recipe f{T<:Number}(xyz::AVec{FixedSizeArrays.Vec{3,T}}) = unzip(xyz) @recipe f(xyz::AVec{FixedSizeArrays.Vec{3,T}}) where {T<:Number} = unzip(xyz)
@recipe f{T<:Number}(xyz::FixedSizeArrays.Vec{3,T}) = [xyz[1]], [xyz[2]], [xyz[3]] @recipe f(xyz::FixedSizeArrays.Vec{3,T}) where {T<:Number} = [xyz[1]], [xyz[2]], [xyz[3]]
# #
# # -------------------------------------------------------------------- # # --------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
function Subplot{T<:AbstractBackend}(::T; parent = RootLayout()) function Subplot(::T; parent = RootLayout()) where T<:AbstractBackend
Subplot{T}( Subplot{T}(
parent, parent,
Series[], Series[],

View File

@ -6,20 +6,20 @@ const AVec = AbstractVector
const AMat = AbstractMatrix const AMat = AbstractMatrix
const KW = Dict{Symbol,Any} const KW = Dict{Symbol,Any}
immutable PlotsDisplay <: Display end struct PlotsDisplay <: Display end
# ----------------------------------------------------------- # -----------------------------------------------------------
immutable InputWrapper{T} struct InputWrapper{T}
obj::T obj::T
end end
wrap{T}(obj::T) = InputWrapper{T}(obj) wrap(obj::T) where {T} = InputWrapper{T}(obj)
Base.isempty(wrapper::InputWrapper) = false Base.isempty(wrapper::InputWrapper) = false
# ----------------------------------------------------------- # -----------------------------------------------------------
type Series mutable struct Series
d::KW d::KW
end end
@ -29,7 +29,7 @@ attr!(series::Series, v, k::Symbol) = (series.d[k] = v)
# ----------------------------------------------------------- # -----------------------------------------------------------
# a single subplot # a single subplot
type Subplot{T<:AbstractBackend} <: AbstractLayout mutable struct Subplot{T<:AbstractBackend} <: AbstractLayout
parent::AbstractLayout parent::AbstractLayout
series_list::Vector{Series} # arguments for each series series_list::Vector{Series} # arguments for each series
minpad::Tuple # leftpad, toppad, rightpad, bottompad minpad::Tuple # leftpad, toppad, rightpad, bottompad
@ -45,12 +45,12 @@ Base.show(io::IO, sp::Subplot) = print(io, "Subplot{$(sp[:subplot_index])}")
# ----------------------------------------------------------- # -----------------------------------------------------------
# simple wrapper around a KW so we can hold all attributes pertaining to the axis in one place # simple wrapper around a KW so we can hold all attributes pertaining to the axis in one place
type Axis mutable struct Axis
sps::Vector{Subplot} sps::Vector{Subplot}
d::KW d::KW
end end
type Extrema mutable struct Extrema
emin::Float64 emin::Float64
emax::Float64 emax::Float64
end end
@ -63,7 +63,7 @@ const SubplotMap = Dict{Any, Subplot}
# ----------------------------------------------------------- # -----------------------------------------------------------
type Plot{T<:AbstractBackend} <: AbstractPlot{T} mutable struct Plot{T<:AbstractBackend} <: AbstractPlot{T}
backend::T # the backend type backend::T # the backend type
n::Int # number of series n::Int # number of series
attr::KW # arguments for the whole plot attr::KW # arguments for the whole plot

View File

@ -114,7 +114,7 @@ function regressionXY(x, y)
regx, regy regx, regy
end end
function replace_image_with_heatmap{T<:Colorant}(z::Array{T}) function replace_image_with_heatmap(z::Array{T}) where T<:Colorant
@show T, size(z) @show T, size(z)
n, m = size(z) n, m = size(z)
# idx = 0 # idx = 0
@ -138,14 +138,14 @@ end
# --------------------------------------------------------------- # ---------------------------------------------------------------
"Build line segments for plotting" "Build line segments for plotting"
type Segments{T} mutable struct Segments{T}
pts::Vector{T} pts::Vector{T}
end end
# Segments() = Segments{Float64}(zeros(0)) # Segments() = Segments{Float64}(zeros(0))
Segments() = Segments(Float64) Segments() = Segments(Float64)
Segments{T}(::Type{T}) = Segments(T[]) Segments(::Type{T}) where {T} = Segments(T[])
Segments(p::Int) = Segments(NTuple{2,Float64}[]) Segments(p::Int) = Segments(NTuple{2,Float64}[])
@ -157,7 +157,7 @@ to_nan(::Type{NTuple{2,Float64}}) = (NaN, NaN)
coords(segs::Segments{Float64}) = segs.pts coords(segs::Segments{Float64}) = segs.pts
coords(segs::Segments{NTuple{2,Float64}}) = Float64[p[1] for p in segs.pts], Float64[p[2] for p in segs.pts] coords(segs::Segments{NTuple{2,Float64}}) = Float64[p[1] for p in segs.pts], Float64[p[2] for p in segs.pts]
function Base.push!{T}(segments::Segments{T}, vs...) function Base.push!(segments::Segments{T}, vs...) where T
if !isempty(segments.pts) if !isempty(segments.pts)
push!(segments.pts, to_nan(T)) push!(segments.pts, to_nan(T))
end end
@ -167,7 +167,7 @@ function Base.push!{T}(segments::Segments{T}, vs...)
segments segments
end end
function Base.push!{T}(segments::Segments{T}, vs::AVec) function Base.push!(segments::Segments{T}, vs::AVec) where T
if !isempty(segments.pts) if !isempty(segments.pts)
push!(segments.pts, to_nan(T)) push!(segments.pts, to_nan(T))
end end
@ -181,7 +181,7 @@ end
# ----------------------------------------------------- # -----------------------------------------------------
# helper to manage NaN-separated segments # helper to manage NaN-separated segments
type SegmentsIterator mutable struct SegmentsIterator
args::Tuple args::Tuple
n::Int n::Int
end end
@ -232,8 +232,8 @@ end
# Find minimal type that can contain NaN and x # Find minimal type that can contain NaN and x
# To allow use of NaN separated segments with categorical x axis # To allow use of NaN separated segments with categorical x axis
float_extended_type{T}(x::AbstractArray{T}) = Union{T,Float64} float_extended_type(x::AbstractArray{T}) where {T} = Union{T,Float64}
float_extended_type{T<:Real}(x::AbstractArray{T}) = Float64 float_extended_type(x::AbstractArray{T}) where {T<:Real} = Float64
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
@ -259,27 +259,27 @@ _cycle(grad::ColorGradient, idx::Int) = _cycle(grad.colors, idx)
_cycle(grad::ColorGradient, indices::AVec{Int}) = _cycle(grad.colors, indices) _cycle(grad::ColorGradient, indices::AVec{Int}) = _cycle(grad.colors, indices)
makevec(v::AVec) = v makevec(v::AVec) = v
makevec{T}(v::T) = T[v] makevec(v::T) where {T} = T[v]
"duplicate a single value, or pass the 2-tuple through" "duplicate a single value, or pass the 2-tuple through"
maketuple(x::Real) = (x,x) maketuple(x::Real) = (x,x)
maketuple{T,S}(x::Tuple{T,S}) = x maketuple(x::Tuple{T,S}) where {T,S} = x
mapFuncOrFuncs(f::Function, u::AVec) = map(f, u) mapFuncOrFuncs(f::Function, u::AVec) = map(f, u)
mapFuncOrFuncs{F<:Function}(fs::AVec{F}, u::AVec) = [map(f, u) for f in fs] mapFuncOrFuncs(fs::AVec{F}, u::AVec) where {F<:Function} = [map(f, u) for f in fs]
unzip{X,Y}(xy::AVec{Tuple{X,Y}}) = [t[1] for t in xy], [t[2] for t in xy] unzip(xy::AVec{Tuple{X,Y}}) where {X,Y} = [t[1] for t in xy], [t[2] for t in xy]
unzip{X,Y,Z}(xyz::AVec{Tuple{X,Y,Z}}) = [t[1] for t in xyz], [t[2] for t in xyz], [t[3] for t in xyz] unzip(xyz::AVec{Tuple{X,Y,Z}}) where {X,Y,Z} = [t[1] for t in xyz], [t[2] for t in xyz], [t[3] for t in xyz]
unzip{X,Y,U,V}(xyuv::AVec{Tuple{X,Y,U,V}}) = [t[1] for t in xyuv], [t[2] for t in xyuv], [t[3] for t in xyuv], [t[4] for t in xyuv] unzip(xyuv::AVec{Tuple{X,Y,U,V}}) where {X,Y,U,V} = [t[1] for t in xyuv], [t[2] for t in xyuv], [t[3] for t in xyuv], [t[4] for t in xyuv]
unzip{T}(xy::AVec{FixedSizeArrays.Vec{2,T}}) = T[t[1] for t in xy], T[t[2] for t in xy] unzip(xy::AVec{FixedSizeArrays.Vec{2,T}}) where {T} = T[t[1] for t in xy], T[t[2] for t in xy]
unzip{T}(xy::FixedSizeArrays.Vec{2,T}) = T[xy[1]], T[xy[2]] unzip(xy::FixedSizeArrays.Vec{2,T}) where {T} = T[xy[1]], T[xy[2]]
unzip{T}(xyz::AVec{FixedSizeArrays.Vec{3,T}}) = T[t[1] for t in xyz], T[t[2] for t in xyz], T[t[3] for t in xyz] unzip(xyz::AVec{FixedSizeArrays.Vec{3,T}}) where {T} = T[t[1] for t in xyz], T[t[2] for t in xyz], T[t[3] for t in xyz]
unzip{T}(xyz::FixedSizeArrays.Vec{3,T}) = T[xyz[1]], T[xyz[2]], T[xyz[3]] unzip(xyz::FixedSizeArrays.Vec{3,T}) where {T} = T[xyz[1]], T[xyz[2]], T[xyz[3]]
unzip{T}(xyuv::AVec{FixedSizeArrays.Vec{4,T}}) = T[t[1] for t in xyuv], T[t[2] for t in xyuv], T[t[3] for t in xyuv], T[t[4] for t in xyuv] unzip(xyuv::AVec{FixedSizeArrays.Vec{4,T}}) where {T} = T[t[1] for t in xyuv], T[t[2] for t in xyuv], T[t[3] for t in xyuv], T[t[4] for t in xyuv]
unzip{T}(xyuv::FixedSizeArrays.Vec{4,T}) = T[xyuv[1]], T[xyuv[2]], T[xyuv[3]], T[xyuv[4]] unzip(xyuv::FixedSizeArrays.Vec{4,T}) where {T} = T[xyuv[1]], T[xyuv[2]], T[xyuv[3]], T[xyuv[4]]
# given 2-element lims and a vector of data x, widen lims to account for the extrema of x # given 2-element lims and a vector of data x, widen lims to account for the extrema of x
function _expand_limits(lims, x) function _expand_limits(lims, x)
@ -388,7 +388,7 @@ isatom() = isdefined(Main, :Atom) && Main.Atom.isconnected()
function is_installed(pkgstr::AbstractString) function is_installed(pkgstr::AbstractString)
try try
Pkg.installed(pkgstr) === nothing ? false: true Pkg.installed(pkgstr) === nothing ? false : true
catch catch
false false
end end
@ -410,20 +410,20 @@ isvertical(d::KW) = get(d, :orientation, :vertical) in (:vertical, :v, :vert)
isvertical(series::Series) = isvertical(series.d) isvertical(series::Series) = isvertical(series.d)
ticksType{T<:Real}(ticks::AVec{T}) = :ticks ticksType(ticks::AVec{T}) where {T<:Real} = :ticks
ticksType{T<:AbstractString}(ticks::AVec{T}) = :labels ticksType(ticks::AVec{T}) where {T<:AbstractString} = :labels
ticksType{T<:AVec,S<:AVec}(ticks::Tuple{T,S}) = :ticks_and_labels ticksType(ticks::Tuple{T,S}) where {T<:AVec,S<:AVec} = :ticks_and_labels
ticksType(ticks) = :invalid ticksType(ticks) = :invalid
limsType{T<:Real,S<:Real}(lims::Tuple{T,S}) = :limits limsType(lims::Tuple{T,S}) where {T<:Real,S<:Real} = :limits
limsType(lims::Symbol) = lims == :auto ? :auto : :invalid limsType(lims::Symbol) = lims == :auto ? :auto : :invalid
limsType(lims) = :invalid 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{T<:Real}(::Type{Vector{T}}, rng::Range{T}) = T[x for x in rng] Base.convert(::Type{Vector{T}}, rng::Range{T}) where {T<:Real} = T[x for x in rng]
Base.convert{T<:Real,S<:Real}(::Type{Vector{T}}, rng::Range{S}) = 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.merge(a::AbstractVector, b::AbstractVector) = sort(unique(vcat(a,b))) Base.merge(a::AbstractVector, b::AbstractVector) = sort(unique(vcat(a,b)))
@ -727,7 +727,7 @@ end
# --------------------------------------------------------------- # ---------------------------------------------------------------
# --------------------------------------------------------------- # ---------------------------------------------------------------
type DebugMode mutable struct DebugMode
on::Bool on::Bool
end end
const _debugMode = DebugMode(false) const _debugMode = DebugMode(false)
@ -765,10 +765,10 @@ 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{T}(v::Range{T}, z::Real) = extendSeriesData(float(collect(v)), z) extendSeriesData(v::Range{T}, z::Real) where {T} = extendSeriesData(float(collect(v)), z)
extendSeriesData{T}(v::Range{T}, z::AVec) = extendSeriesData(float(collect(v)), z) extendSeriesData(v::Range{T}, z::AVec) where {T} = extendSeriesData(float(collect(v)), z)
extendSeriesData{T}(v::AVec{T}, z::Real) = (push!(v, convert(T, z)); v) extendSeriesData(v::AVec{T}, z::Real) where {T} = (push!(v, convert(T, z)); v)
extendSeriesData{T}(v::AVec{T}, z::AVec) = (append!(v, convert(Vector{T}, z)); v) extendSeriesData(v::AVec{T}, z::AVec) where {T} = (append!(v, convert(Vector{T}, z)); v)
# ------------------------------------------------------- # -------------------------------------------------------
@ -786,14 +786,14 @@ function getxyz(plt::Plot, i::Integer)
tovec(d[:x]), tovec(d[:y]), tovec(d[:z]) tovec(d[:x]), tovec(d[:y]), tovec(d[:z])
end end
function setxy!{X,Y}(plt::Plot, xy::Tuple{X,Y}, i::Integer) function setxy!(plt::Plot, xy::Tuple{X,Y}, i::Integer) where {X,Y}
series = plt.series_list[i] series = plt.series_list[i]
series.d[:x], series.d[:y] = xy series.d[:x], series.d[:y] = xy
sp = series.d[:subplot] sp = series.d[:subplot]
reset_extrema!(sp) reset_extrema!(sp)
_series_updated(plt, series) _series_updated(plt, series)
end end
function setxyz!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) function setxyz!(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) where {X,Y,Z}
series = plt.series_list[i] series = plt.series_list[i]
series.d[:x], series.d[:y], series.d[:z] = xyz series.d[:x], series.d[:y], series.d[:z] = xyz
sp = series.d[:subplot] sp = series.d[:subplot]
@ -801,7 +801,7 @@ function setxyz!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer)
_series_updated(plt, series) _series_updated(plt, series)
end end
function setxyz!{X,Y,Z<:AbstractMatrix}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) function setxyz!(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) where {X,Y,Z<:AbstractMatrix}
setxyz!(plt, (xyz[1], xyz[2], Surface(xyz[3])), i) setxyz!(plt, (xyz[1], xyz[2], Surface(xyz[3])), i)
end end
@ -810,8 +810,8 @@ end
# indexing notation # indexing notation
# Base.getindex(plt::Plot, i::Integer) = getxy(plt, i) # Base.getindex(plt::Plot, i::Integer) = getxy(plt, i)
Base.setindex!{X,Y}(plt::Plot, xy::Tuple{X,Y}, i::Integer) = (setxy!(plt, xy, i); plt) Base.setindex!(plt::Plot, xy::Tuple{X,Y}, i::Integer) where {X,Y} = (setxy!(plt, xy, i); plt)
Base.setindex!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) = (setxyz!(plt, xyz, i); plt) Base.setindex!(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) where {X,Y,Z} = (setxyz!(plt, xyz, i); plt)
# ------------------------------------------------------- # -------------------------------------------------------
@ -923,10 +923,10 @@ function Base.append!(plt::Plot, i::Integer, x::AVec, y::AVec, z::AVec)
end end
# tuples # tuples
Base.push!{X,Y}(plt::Plot, xy::Tuple{X,Y}) = push!(plt, 1, xy...) Base.push!(plt::Plot, xy::Tuple{X,Y}) where {X,Y} = push!(plt, 1, xy...)
Base.push!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}) = push!(plt, 1, xyz...) Base.push!(plt::Plot, xyz::Tuple{X,Y,Z}) where {X,Y,Z} = push!(plt, 1, xyz...)
Base.push!{X,Y}(plt::Plot, i::Integer, xy::Tuple{X,Y}) = push!(plt, i, xy...) Base.push!(plt::Plot, i::Integer, xy::Tuple{X,Y}) where {X,Y} = push!(plt, i, xy...)
Base.push!{X,Y,Z}(plt::Plot, i::Integer, xyz::Tuple{X,Y,Z}) = push!(plt, i, xyz...) Base.push!(plt::Plot, i::Integer, xyz::Tuple{X,Y,Z}) where {X,Y,Z} = push!(plt, i, xyz...)
# ------------------------------------------------------- # -------------------------------------------------------
# push/append for all series # push/append for all series