working on 0.5 changes

This commit is contained in:
Thomas Breloff 2016-05-28 10:42:41 -04:00
parent ce82e07dc9
commit 0a86ccb142
19 changed files with 134 additions and 135 deletions

View File

@ -203,7 +203,7 @@ include("output.jl")
# define and export shorthand plotting method definitions # define and export shorthand plotting method definitions
macro shorthands(funcname::Symbol) macro shorthands(funcname::Symbol)
funcname2 = symbol(funcname, "!") funcname2 = Symbol(funcname, "!")
ret = esc(quote ret = esc(quote
export $funcname, $funcname2 export $funcname, $funcname2
$funcname(args...; kw...) = plot(args...; kw..., seriestype = $(quot(funcname))) $funcname(args...; kw...) = plot(args...; kw..., seriestype = $(quot(funcname)))
@ -285,9 +285,9 @@ plot3d!(args...; kw...) = plot!(args...; kw..., seriestype = :path3d)
# quiver!(args...; kw...) = plot!(args...; kw..., seriestype = :quiver) # quiver!(args...; kw...) = plot!(args...; kw..., seriestype = :quiver)
title!(s::AbstractString; kw...) = plot!(; title = s, kw...) title!(s::@compat(String); kw...) = plot!(; title = s, kw...)
xlabel!(s::AbstractString; kw...) = plot!(; xlabel = s, kw...) xlabel!(s::@compat(String); kw...) = plot!(; xlabel = s, kw...)
ylabel!(s::AbstractString; kw...) = plot!(; ylabel = s, kw...) ylabel!(s::@compat(String); kw...) = plot!(; ylabel = s, kw...)
xlims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; xlims = lims, kw...) xlims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; xlims = lims, kw...)
ylims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; ylims = lims, kw...) ylims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; ylims = lims, kw...)
zlims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; zlims = lims, kw...) zlims!{T<:Real,S<:Real}(lims::Tuple{T,S}; kw...) = plot!(; zlims = lims, kw...)
@ -296,9 +296,9 @@ ylims!(ymin::Real, ymax::Real; kw...) = plot!(; ylims = (ymi
zlims!(zmin::Real, zmax::Real; kw...) = plot!(; zlims = (zmin,zmax), kw...) zlims!(zmin::Real, zmax::Real; kw...) = plot!(; zlims = (zmin,zmax), kw...)
xticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; xticks = v, kw...) xticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; xticks = v, kw...)
yticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; yticks = v, kw...) yticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; yticks = v, kw...)
xticks!{T<:Real,S<:AbstractString}( xticks!{T<:Real,S<:@compat(String)}(
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; xticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; xticks = (ticks,labels), kw...)
yticks!{T<:Real,S<:AbstractString}( yticks!{T<:Real,S<:@compat(String)}(
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; yticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; yticks = (ticks,labels), kw...)
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!{T<:Tuple}(anns::AVec{T}; kw...) = plot!(; annotation = anns, kw...)
@ -307,9 +307,9 @@ yflip!(flip::Bool = true; kw...) = plot!(; yflip = flip
xaxis!(args...; kw...) = plot!(; xaxis = args, kw...) xaxis!(args...; kw...) = plot!(; xaxis = args, kw...)
yaxis!(args...; kw...) = plot!(; yaxis = args, kw...) yaxis!(args...; kw...) = plot!(; yaxis = args, kw...)
title!(plt::Plot, s::AbstractString; kw...) = plot!(plt; title = s, kw...) title!(plt::Plot, s::@compat(String); kw...) = plot!(plt; title = s, kw...)
xlabel!(plt::Plot, s::AbstractString; kw...) = plot!(plt; xlabel = s, kw...) xlabel!(plt::Plot, s::@compat(String); kw...) = plot!(plt; xlabel = s, kw...)
ylabel!(plt::Plot, s::AbstractString; kw...) = plot!(plt; ylabel = s, kw...) ylabel!(plt::Plot, s::@compat(String); kw...) = plot!(plt; ylabel = s, kw...)
xlims!{T<:Real,S<:Real}(plt::Plot, lims::Tuple{T,S}; kw...) = plot!(plt; xlims = lims, kw...) xlims!{T<:Real,S<:Real}(plt::Plot, lims::Tuple{T,S}; kw...) = plot!(plt; xlims = lims, kw...)
ylims!{T<:Real,S<:Real}(plt::Plot, lims::Tuple{T,S}; kw...) = plot!(plt; ylims = lims, kw...) ylims!{T<:Real,S<:Real}(plt::Plot, lims::Tuple{T,S}; kw...) = plot!(plt; ylims = lims, kw...)
zlims!{T<:Real,S<:Real}(plt::Plot, lims::Tuple{T,S}; kw...) = plot!(plt; zlims = lims, kw...) zlims!{T<:Real,S<:Real}(plt::Plot, lims::Tuple{T,S}; kw...) = plot!(plt; zlims = lims, kw...)
@ -318,9 +318,9 @@ ylims!(plt::Plot, ymin::Real, ymax::Real; kw...) = plot!(pl
zlims!(plt::Plot, zmin::Real, zmax::Real; kw...) = plot!(plt; zlims = (zmin,zmax), kw...) zlims!(plt::Plot, zmin::Real, zmax::Real; kw...) = plot!(plt; zlims = (zmin,zmax), kw...)
xticks!{T<:Real}(plt::Plot, ticks::AVec{T}; kw...) = plot!(plt; xticks = ticks, kw...) xticks!{T<:Real}(plt::Plot, ticks::AVec{T}; kw...) = plot!(plt; xticks = ticks, kw...)
yticks!{T<:Real}(plt::Plot, ticks::AVec{T}; kw...) = plot!(plt; yticks = ticks, kw...) yticks!{T<:Real}(plt::Plot, ticks::AVec{T}; kw...) = plot!(plt; yticks = ticks, kw...)
xticks!{T<:Real,S<:AbstractString}(plt::Plot, xticks!{T<:Real,S<:@compat(String)}(plt::Plot,
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; xticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; xticks = (ticks,labels), kw...)
yticks!{T<:Real,S<:AbstractString}(plt::Plot, yticks!{T<:Real,S<:@compat(String)}(plt::Plot,
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; yticks = (ticks,labels), kw...) ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; yticks = (ticks,labels), kw...)
annotate!(plt::Plot, anns...; kw...) = plot!(plt; annotation = anns, kw...) annotate!(plt::Plot, anns...; kw...) = plot!(plt; annotation = anns, kw...)
annotate!{T<:Tuple}(plt::Plot, anns::AVec{T}; kw...) = plot!(plt; annotation = anns, kw...) annotate!{T<:Tuple}(plt::Plot, anns::AVec{T}; kw...) = plot!(plt; annotation = anns, kw...)

View File

@ -1,12 +1,12 @@
immutable Animation immutable Animation
dir::ASCIIString dir::@compat(String)
frames::Vector{ASCIIString} frames::Vector{@compat(String)}
end end
function Animation() function Animation()
tmpdir = convert(ASCIIString, mktempdir()) tmpdir = convert(@compat(String), mktempdir())
Animation(tmpdir, ASCIIString[]) Animation(tmpdir, @compat(String)[])
end end
function frame{P<:AbstractPlot}(anim::Animation, plt::P=current()) function frame{P<:AbstractPlot}(anim::Animation, plt::P=current())
@ -21,10 +21,10 @@ 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 immutable AnimatedGif
filename::ASCIIString filename::@compat(String)
end end
function gif(anim::Animation, fn::@compat(AbstractString) = "tmp.gif"; fps::Integer = 20) function gif(anim::Animation, fn::@compat(String) = "tmp.gif"; fps::Integer = 20)
fn = abspath(fn) fn = abspath(fn)
try try

View File

@ -272,10 +272,10 @@ for letter in (:x,:y,:z)
:foreground_color_guide, :foreground_color_guide,
:discrete_values :discrete_values
) )
_axis_defaults_byletter[symbol(letter,k)] = nothing _axis_defaults_byletter[Symbol(letter,k)] = nothing
# allow the underscore version too: xguide or x_guide # allow the underscore version too: xguide or x_guide
add_aliases(symbol(letter, k), symbol(letter, "_", k)) add_aliases(Symbol(letter, k), Symbol(letter, "_", k))
end end
end end
@ -294,7 +294,7 @@ RecipesBase.is_key_supported(k::Symbol) = (k in supportedArgs())
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
makeplural(s::Symbol) = symbol(string(s,"s")) makeplural(s::Symbol) = Symbol(string(s,"s"))
autopick(arr::AVec, idx::Integer) = arr[mod1(idx,length(arr))] autopick(arr::AVec, idx::Integer) = arr[mod1(idx,length(arr))]
autopick(notarr, idx::Integer) = notarr autopick(notarr, idx::Integer) = notarr
@ -592,7 +592,7 @@ function preprocessArgs!(d::KW)
# handle axis args # handle axis args
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
asym = symbol(letter, :axis) asym = Symbol(letter, :axis)
args = pop!(d, asym, ()) args = pop!(d, asym, ())
if !(typeof(args) <: Axis) if !(typeof(args) <: Axis)
for arg in wraptuple(args) for arg in wraptuple(args)
@ -678,7 +678,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 type GroupBy
groupLabels::Vector{UTF8String} # length == numGroups groupLabels::Vector{@compat(String)} # length == numGroups
groupIds::Vector{Vector{Int}} # list of indices for each group groupIds::Vector{Vector{Int}} # list of indices for each group
end end
@ -869,7 +869,7 @@ function _update_subplot_args(plt::Plot, sp::Subplot, d_in::KW, subplot_index::I
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
# get (maybe initialize) the axis # get (maybe initialize) the axis
axissym = symbol(letter, :axis) axissym = Symbol(letter, :axis)
axis = if haskey(spargs, axissym) axis = if haskey(spargs, axissym)
spargs[axissym] spargs[axissym]
else else
@ -891,7 +891,7 @@ function _update_subplot_args(plt::Plot, sp::Subplot, d_in::KW, subplot_index::I
end end
# then get those args that were passed with a leading letter: `xlabel = "X"` # then get those args that were passed with a leading letter: `xlabel = "X"`
lk = symbol(letter, k) lk = Symbol(letter, k)
if haskey(d_in, lk) if haskey(d_in, lk)
kw[k] = slice_arg(pop!(d_in, lk), subplot_index) kw[k] = slice_arg(pop!(d_in, lk), subplot_index)
end end

View File

@ -29,32 +29,32 @@ function process_axis_arg!(d::KW, arg, letter = "")
arg = get(_scaleAliases, arg, arg) arg = get(_scaleAliases, arg, arg)
if typeof(arg) <: Font if typeof(arg) <: Font
d[symbol(letter,:tickfont)] = arg d[Symbol(letter,:tickfont)] = arg
d[symbol(letter,:guidefont)] = arg d[Symbol(letter,:guidefont)] = arg
elseif arg in _allScales elseif arg in _allScales
d[symbol(letter,:scale)] = arg d[Symbol(letter,:scale)] = arg
elseif arg in (:flip, :invert, :inverted) elseif arg in (:flip, :invert, :inverted)
d[symbol(letter,:flip)] = true d[Symbol(letter,:flip)] = true
elseif T <: @compat(AbstractString) elseif T <: @compat(String)
d[symbol(letter,:guide)] = arg d[Symbol(letter,:guide)] = arg
# xlims/ylims # xlims/ylims
elseif (T <: Tuple || T <: AVec) && length(arg) == 2 elseif (T <: Tuple || T <: AVec) && length(arg) == 2
sym = typeof(arg[1]) <: Number ? :lims : :ticks sym = typeof(arg[1]) <: Number ? :lims : :ticks
d[symbol(letter,sym)] = arg d[Symbol(letter,sym)] = arg
# xticks/yticks # xticks/yticks
elseif T <: AVec elseif T <: AVec
d[symbol(letter,:ticks)] = arg d[Symbol(letter,:ticks)] = arg
elseif arg == nothing elseif arg == nothing
d[symbol(letter,:ticks)] = [] d[Symbol(letter,:ticks)] = []
elseif typeof(arg) <: Number elseif typeof(arg) <: Number
d[symbol(letter,:rotation)] = arg d[Symbol(letter,:rotation)] = arg
else else
warn("Skipped $(letter)axis arg $arg") warn("Skipped $(letter)axis arg $arg")

View File

@ -12,16 +12,16 @@ _backend_instance(sym::Symbol) = haskey(_backendType, sym) ? _backendType[sym]()
macro init_backend(s) macro init_backend(s)
str = lowercase(string(s)) str = lowercase(string(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 immutable $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)
push!(_backends, symbol($str)) push!(_backends, Symbol($str))
_backendType[symbol($str)] = $T _backendType[Symbol($str)] = $T
_backendSymbol[$T] = symbol($str) _backendSymbol[$T] = Symbol($str)
include("backends/" * $str * ".jl") include("backends/" * $str * ".jl")
end) end)
end end
@ -86,7 +86,7 @@ function pickDefaultBackend()
if env_default != "" if env_default != ""
try try
Pkg.installed(env_default) # this will error if not installed Pkg.installed(env_default) # this will error if not installed
sym = symbol(lowercase(env_default)) sym = Symbol(lowercase(env_default))
if haskey(_backendType, sym) if haskey(_backendType, sym)
return backend(sym) return backend(sym)
else else
@ -103,7 +103,7 @@ function pickDefaultBackend()
# features, speed, and robustness # features, speed, and robustness
for pkgstr in ("PyPlot", "GR", "PlotlyJS", "Immerse", "Gadfly", "UnicodePlots") for pkgstr in ("PyPlot", "GR", "PlotlyJS", "Immerse", "Gadfly", "UnicodePlots")
if Pkg.installed(pkgstr) != nothing if Pkg.installed(pkgstr) != nothing
return backend(symbol(lowercase(pkgstr))) return backend(Symbol(lowercase(pkgstr)))
end end
end end

View File

@ -1236,8 +1236,8 @@ const _gr_mimeformats = Dict(
for (mime, fmt) in _gr_mimeformats for (mime, fmt) in _gr_mimeformats
# @eval function Base.writemime(io::IO, ::MIME{symbol($mime)}, plt::Plot{PyPlotBackend}) # @eval function Base.writemime(io::IO, ::MIME{Symbol($mime)}, plt::Plot{PyPlotBackend})
@eval function _writemime(io::IO, ::MIME{symbol($mime)}, plt::Plot{GRBackend}) @eval function _writemime(io::IO, ::MIME{Symbol($mime)}, plt::Plot{GRBackend})
GR.emergencyclosegks() GR.emergencyclosegks()
ENV["GKS_WSTYPE"] = $fmt ENV["GKS_WSTYPE"] = $fmt
gr_display(plt) gr_display(plt)

View File

@ -198,12 +198,12 @@ end
# ---------------------------------------------------------------- # ----------------------------------------------------------------
function pgf_axis(sp::Subplot, letter) function pgf_axis(sp::Subplot, letter)
axis = sp.attr[symbol(letter,:axis)] axis = sp.attr[Symbol(letter,:axis)]
style = [] style = []
kw = KW() kw = KW()
# axis guide # axis guide
kw[symbol(letter,:label)] = axis[:guide] kw[Symbol(letter,:label)] = axis[:guide]
# flip/reverse? # flip/reverse?
axis[:flip] && push!(style, "$letter dir=reverse") axis[:flip] && push!(style, "$letter dir=reverse")
@ -211,14 +211,14 @@ function pgf_axis(sp::Subplot, letter)
# scale # scale
scale = axis[:scale] scale = axis[:scale]
if scale in (:log2, :ln, :log10) if scale in (:log2, :ln, :log10)
kw[symbol(letter,:mode)] = "log" kw[Symbol(letter,:mode)] = "log"
scale == :ln || push!(style, "log basis $letter=$(scale == :log2 ? 2 : 10)") scale == :ln || push!(style, "log basis $letter=$(scale == :log2 ? 2 : 10)")
end end
# limits # limits
lims = axis_limits(axis) lims = axis_limits(axis)
kw[symbol(letter,:min)] = lims[1] kw[Symbol(letter,:min)] = lims[1]
kw[symbol(letter,:max)] = lims[2] kw[Symbol(letter,:max)] = lims[2]
# return the style list and KW args # return the style list and KW args
style, kw style, kw

View File

@ -158,7 +158,7 @@ function plotlyfont(font::Font, color = font.color)
) )
end end
function get_annotation_dict(x, y, val::Union{AbstractString,Symbol}) function get_annotation_dict(x, y, val::Union{@compat(String),Symbol})
KW( KW(
:text => val, :text => val,
:xref => "x", :xref => "x",
@ -232,12 +232,12 @@ function _update_min_padding!(sp::Subplot{PlotlyBackend})
sp.minpad = plotly_minpad(sp) sp.minpad = plotly_minpad(sp)
end end
# tickssym(letter) = symbol(letter * "ticks") # tickssym(letter) = Symbol(letter * "ticks")
# limssym(letter) = symbol(letter * "lims") # limssym(letter) = Symbol(letter * "lims")
# flipsym(letter) = symbol(letter * "flip") # flipsym(letter) = Symbol(letter * "flip")
# scalesym(letter) = symbol(letter * "scale") # scalesym(letter) = Symbol(letter * "scale")
# labelsym(letter) = symbol(letter * "label") # labelsym(letter) = Symbol(letter * "label")
# rotationsym(letter) = symbol(letter * "rotation") # rotationsym(letter) = Symbol(letter * "rotation")
function plotly_axis(axis::Axis, sp::Subplot) function plotly_axis(axis::Axis, sp::Subplot)
letter = axis[:letter] letter = axis[:letter]
@ -336,13 +336,13 @@ function plotly_layout(plt::Plot)
# if any(is3d, seriesargs) # if any(is3d, seriesargs)
if is3d(sp) if is3d(sp)
d_out[:scene] = KW( d_out[:scene] = KW(
symbol("xaxis$spidx") => plotly_axis(sp.attr[:xaxis], sp), Symbol("xaxis$spidx") => plotly_axis(sp.attr[:xaxis], sp),
symbol("yaxis$spidx") => plotly_axis(sp.attr[:yaxis], sp), Symbol("yaxis$spidx") => plotly_axis(sp.attr[:yaxis], sp),
symbol("zaxis$spidx") => plotly_axis(sp.attr[:zaxis], sp), Symbol("zaxis$spidx") => plotly_axis(sp.attr[:zaxis], sp),
) )
else else
d_out[symbol("xaxis$spidx")] = plotly_axis(sp.attr[:xaxis], sp) d_out[Symbol("xaxis$spidx")] = plotly_axis(sp.attr[:xaxis], sp)
d_out[symbol("yaxis$spidx")] = plotly_axis(sp.attr[:yaxis], sp) d_out[Symbol("yaxis$spidx")] = plotly_axis(sp.attr[:yaxis], sp)
end end
# legend # legend

View File

@ -85,7 +85,7 @@ function _initialize_backend(::PlotlyJSBackend; kw...)
for (mime, fmt) in PlotlyJS._mimeformats for (mime, fmt) in PlotlyJS._mimeformats
# mime == "image/png" && continue # don't use plotlyjs's writemime for png # mime == "image/png" && continue # don't use plotlyjs's writemime for png
@eval Base.writemime(io::IO, m::MIME{symbol($mime)}, p::Plot{PlotlyJSBackend}) = writemime(io, m, p.o) @eval Base.writemime(io::IO, m::MIME{Symbol($mime)}, p::Plot{PlotlyJSBackend}) = writemime(io, m, p.o)
end end
# override IJulia inline display # override IJulia inline display

View File

@ -196,7 +196,7 @@ function getPyPlotMarker(markers::AVec)
end end
# pass through # pass through
function getPyPlotMarker(marker::AbstractString) function getPyPlotMarker(marker::@compat(String))
@assert length(marker) == 1 @assert length(marker) == 1
marker marker
end end
@ -325,13 +325,13 @@ end
# bounding box: union of axis tick labels # bounding box: union of axis tick labels
function py_bbox_ticks(ax, letter) function py_bbox_ticks(ax, letter)
labels = ax[symbol("get_"*letter*"ticklabels")]() labels = ax[Symbol("get_"*letter*"ticklabels")]()
py_bbox(labels) py_bbox(labels)
end end
# bounding box: axis guide # bounding box: axis guide
function py_bbox_axislabel(ax, letter) function py_bbox_axislabel(ax, letter)
pyaxis_label = ax[symbol("get_"*letter*"axis")]()[:label] pyaxis_label = ax[Symbol("get_"*letter*"axis")]()[:label]
py_bbox(pyaxis_label) py_bbox(pyaxis_label)
end end
@ -856,21 +856,21 @@ end
# # TODO: check for polar, do set_tlim/set_rlim instead # # TODO: check for polar, do set_tlim/set_rlim instead
# #
# # pyplot's set_xlim (or y/z) method: # # pyplot's set_xlim (or y/z) method:
# sp.o[symbol(:set_, axis[:letter], :lim)](lims...) # sp.o[Symbol(:set_, axis[:letter], :lim)](lims...)
# end # end
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# get_axis and update_limits! should be moved to subplots.jl? or axes.jl? # get_axis and update_limits! should be moved to subplots.jl? or axes.jl?
get_axis(sp::Subplot, letter::Symbol) = sp.attr[symbol(letter, :axis)] get_axis(sp::Subplot, letter::Symbol) = sp.attr[Symbol(letter, :axis)]
function update_limits!(sp::Subplot{PyPlotBackend}, series::Series, letters) function update_limits!(sp::Subplot{PyPlotBackend}, series::Series, letters)
for letter in letters for letter in letters
# axis = get_axis(sp, letter) # axis = get_axis(sp, letter)
# expand_extrema!(axis, series.d[letter]) # expand_extrema!(axis, series.d[letter])
# set_lims!(sp, axis) # set_lims!(sp, axis)
setPyPlotLims(sp.o, sp.attr[symbol(letter, :axis)]) setPyPlotLims(sp.o, sp.attr[Symbol(letter, :axis)])
end end
end end
@ -925,7 +925,7 @@ end
# lims == :auto && return # lims == :auto && return
# ltype = limsType(lims) # ltype = limsType(lims)
# if ltype == :limits # if ltype == :limits
# setf = ax[symbol("set_", letter, "lim")] # setf = ax[Symbol("set_", letter, "lim")]
# l1, l2 = lims # l1, l2 = lims
# if isfinite(l1) # if isfinite(l1)
# letter == :x ? setf(left = l1) : setf(bottom = l1) # letter == :x ? setf(left = l1) : setf(bottom = l1)
@ -941,16 +941,16 @@ end
function setPyPlotLims(ax, axis::Axis) function setPyPlotLims(ax, axis::Axis)
letter = axis[:letter] letter = axis[:letter]
lims = axis_limits(axis) lims = axis_limits(axis)
ax[symbol("set_", letter, "lim")](lims...) ax[Symbol("set_", letter, "lim")](lims...)
end end
function addPyPlotTicks(ax, ticks, letter) function addPyPlotTicks(ax, ticks, letter)
ticks == :auto && return ticks == :auto && return
axis = ax[symbol(letter,"axis")] axis = ax[Symbol(letter,"axis")]
if ticks == :none || ticks == nothing if ticks == :none || ticks == nothing
kw = KW() kw = KW()
for dir in (:top,:bottom,:left,:right) for dir in (:top,:bottom,:left,:right)
kw[dir] = kw[symbol(:label,dir)] = "off" kw[dir] = kw[Symbol(:label,dir)] = "off"
end end
axis[:set_tick_params](;which="both", kw...) axis[:set_tick_params](;which="both", kw...)
return return
@ -968,7 +968,7 @@ function addPyPlotTicks(ax, ticks, letter)
end end
function applyPyPlotScale(ax, scaleType::Symbol, letter) function applyPyPlotScale(ax, scaleType::Symbol, letter)
func = ax[symbol("set_", letter, "scale")] func = ax[Symbol("set_", letter, "scale")]
scaleType == :identity && return func("linear") scaleType == :identity && return func("linear")
scaleType == :ln && return func("log", basex = e, basey = e) scaleType == :ln && return func("log", basex = e, basey = e)
scaleType == :log2 && return func("log", basex = 2, basey = 2) scaleType == :log2 && return func("log", basex = 2, basey = 2)
@ -981,7 +981,7 @@ function updateAxisColors(ax, a::Axis)
for (loc, spine) in ax[:spines] for (loc, spine) in ax[:spines]
spine[:set_color](getPyPlotColor(a[:foreground_color_border])) spine[:set_color](getPyPlotColor(a[:foreground_color_border]))
end end
axissym = symbol(a[:letter], :axis) axissym = Symbol(a[:letter], :axis)
if haskey(ax, axissym) if haskey(ax, axissym)
ax[:tick_params](axis=string(a[:letter]), which="both", ax[:tick_params](axis=string(a[:letter]), which="both",
colors=getPyPlotColor(a[:foreground_color_axis]), colors=getPyPlotColor(a[:foreground_color_axis]),
@ -1025,18 +1025,18 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
# axis attributes # axis attributes
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
axissym = symbol(letter, :axis) axissym = Symbol(letter, :axis)
axis = attr[axissym] axis = attr[axissym]
haskey(ax, axissym) || continue haskey(ax, axissym) || continue
applyPyPlotScale(ax, axis[:scale], letter) applyPyPlotScale(ax, axis[:scale], letter)
setPyPlotLims(ax, axis) setPyPlotLims(ax, axis)
addPyPlotTicks(ax, get_ticks(axis), letter) addPyPlotTicks(ax, get_ticks(axis), letter)
ax[symbol("set_", letter, "label")](axis[:guide]) ax[Symbol("set_", letter, "label")](axis[:guide])
if get(axis.d, :flip, false) if get(axis.d, :flip, false)
ax[symbol("invert_", letter, "axis")]() ax[Symbol("invert_", letter, "axis")]()
end end
ax[axissym][:label][:set_fontsize](axis[:guidefont].pointsize) ax[axissym][:label][:set_fontsize](axis[:guidefont].pointsize)
for lab in ax[symbol("get_", letter, "ticklabels")]() for lab in ax[Symbol("get_", letter, "ticklabels")]()
lab[:set_fontsize](axis[:tickfont].pointsize) lab[:set_fontsize](axis[:tickfont].pointsize)
lab[:set_rotation](axis[:rotation]) lab[:set_rotation](axis[:rotation])
end end
@ -1096,7 +1096,7 @@ end
# ----------------------------------------------------------------- # -----------------------------------------------------------------
function createPyPlotAnnotationObject(sp::Subplot{PyPlotBackend}, x, y, val::@compat(AbstractString)) function createPyPlotAnnotationObject(sp::Subplot{PyPlotBackend}, x, y, val::@compat(String))
ax = sp.o ax = sp.o
ax[:annotate](val, xy = (x,y)) ax[:annotate](val, xy = (x,y))
end end
@ -1275,8 +1275,8 @@ const _pyplot_mimeformats = Dict(
for (mime, fmt) in _pyplot_mimeformats for (mime, fmt) in _pyplot_mimeformats
# @eval function Base.writemime(io::IO, ::MIME{symbol($mime)}, plt::Plot{PyPlotBackend}) # @eval function Base.writemime(io::IO, ::MIME{Symbol($mime)}, plt::Plot{PyPlotBackend})
@eval function _writemime(io::IO, ::MIME{symbol($mime)}, plt::Plot{PyPlotBackend}) @eval function _writemime(io::IO, ::MIME{Symbol($mime)}, plt::Plot{PyPlotBackend})
# finalizePlot(plt) # finalizePlot(plt)
fig = getfig(plt.o) fig = getfig(plt.o)
fig.o["canvas"][:print_figure]( fig.o["canvas"][:print_figure](

View File

@ -280,7 +280,7 @@ end
# ------------------------------- # -------------------------------
# since this is such a hack, it's only callable using `png`... should error during normal `writemime` # since this is such a hack, it's only callable using `png`... should error during normal `writemime`
function png(plt::AbstractPlot{UnicodePlotsBackend}, fn::@compat(AbstractString)) function png(plt::AbstractPlot{UnicodePlotsBackend}, fn::@compat(String))
fn = addExtension(fn, "png") fn = addExtension(fn, "png")
# make some whitespace and show the plot # make some whitespace and show the plot

View File

@ -4,7 +4,7 @@
# CREDIT: parts of this implementation were inspired by @joshday's PlotlyLocal.jl # CREDIT: parts of this implementation were inspired by @joshday's PlotlyLocal.jl
function standalone_html(plt::AbstractPlot; title::AbstractString = get(plt.attr, :window_title, "Plots.jl")) function standalone_html(plt::AbstractPlot; title::@compat(String) = get(plt.attr, :window_title, "Plots.jl"))
""" """
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -19,7 +19,7 @@ function standalone_html(plt::AbstractPlot; title::AbstractString = get(plt.attr
""" """
end end
function open_browser_window(filename::AbstractString) function open_browser_window(filename::@compat(String))
@osx_only return run(`open $(filename)`) @osx_only return run(`open $(filename)`)
@linux_only return run(`xdg-open $(filename)`) @linux_only return run(`xdg-open $(filename)`)
@windows_only return run(`$(ENV["COMSPEC"]) /c start $(filename)`) @windows_only return run(`$(ENV["COMSPEC"]) /c start $(filename)`)

View File

@ -18,7 +18,7 @@ colorscheme(c::Colorant; kw...) = ColorWrapper(c; kw...)
# -------------------------------------------------------------- # --------------------------------------------------------------
convertColor(c::@compat(Union{AbstractString, Symbol})) = parse(Colorant, string(c)) convertColor(c::@compat(Union{@compat(String), Symbol})) = parse(Colorant, string(c))
convertColor(c::Colorant) = c convertColor(c::Colorant) = c
convertColor(cvec::AbstractVector) = map(convertColor, cvec) convertColor(cvec::AbstractVector) = map(convertColor, cvec)
convertColor(c::ColorScheme) = c convertColor(c::ColorScheme) = c
@ -390,7 +390,7 @@ webcolor(c, α) = webcolor(convertColor(getColor(c), α))
# #
# # update sub-background colors # # update sub-background colors
# for bgtype in ("legend", "inside", "outside") # for bgtype in ("legend", "inside", "outside")
# bgsym = symbol("background_color_" * bgtype) # bgsym = Symbol("background_color_" * bgtype)
# if d[bgsym] == :match # if d[bgsym] == :match
# d[bgsym] = d[:background_color] # d[bgsym] = d[:background_color]
# elseif d[bgsym] == nothing # elseif d[bgsym] == nothing
@ -400,7 +400,7 @@ webcolor(c, α) = webcolor(convertColor(getColor(c), α))
# #
# # update sub-foreground colors # # update sub-foreground colors
# for fgtype in ("legend", "grid", "axis", "text", "border", "guide") # for fgtype in ("legend", "grid", "axis", "text", "border", "guide")
# fgsym = symbol("foreground_color_" * fgtype) # fgsym = Symbol("foreground_color_" * fgtype)
# if d[fgsym] == :match # if d[fgsym] == :match
# d[fgsym] = d[:foreground_color] # d[fgsym] = d[:foreground_color]
# elseif d[fgsym] == nothing # elseif d[fgsym] == nothing

View File

@ -110,7 +110,7 @@ const _shapes = KW(
) )
for n in [4,5,6,7,8] for n in [4,5,6,7,8]
_shapes[symbol("star$n")] = makestar(n) _shapes[Symbol("star$n")] = makestar(n)
end end
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
@ -196,7 +196,7 @@ end
immutable Font immutable Font
family::AbstractString family::@compat(String)
pointsize::Int pointsize::Int
halign::Symbol halign::Symbol
valign::Symbol valign::Symbol
@ -227,7 +227,7 @@ function font(args...)
valign = arg valign = arg
elseif T <: Colorant elseif T <: Colorant
color = arg color = arg
elseif T <: @compat Union{Symbol,AbstractString} elseif T <: @compat Union{Symbol,@compat(String)}
try try
color = parse(Colorant, string(arg)) color = parse(Colorant, string(arg))
catch catch
@ -247,7 +247,7 @@ end
"Wrap a string with font info" "Wrap a string with font info"
immutable PlotText immutable PlotText
str::@compat(AbstractString) str::@compat(String)
font::Font font::Font
end end
PlotText(str) = PlotText(string(str), font()) PlotText(str) = PlotText(string(str), font())
@ -287,7 +287,7 @@ function stroke(args...; alpha = nothing)
style = arg style = arg
elseif T <: Colorant elseif T <: Colorant
color = arg color = arg
elseif T <: @compat Union{Symbol,AbstractString} elseif T <: @compat Union{Symbol,@compat(String)}
try try
color = parse(Colorant, string(arg)) color = parse(Colorant, string(arg))
end end
@ -319,7 +319,7 @@ function brush(args...; alpha = nothing)
if T <: Colorant if T <: Colorant
color = arg color = arg
elseif T <: @compat Union{Symbol,AbstractString} elseif T <: @compat Union{Symbol,@compat(String)}
try try
color = parse(Colorant, string(arg)) color = parse(Colorant, string(arg))
end end
@ -367,12 +367,11 @@ Base.copy(surf::Surface) = Surface(copy(surf.surf))
Base.eltype(surf::Surface) = eltype(surf.surf) Base.eltype(surf::Surface) = eltype(surf.surf)
function expand_extrema!(a::Axis, surf::Surface) function expand_extrema!(a::Axis, surf::Surface)
v = surf.surf ex = a[:extrema]
if !isempty(v) for vi in surf.surf
emin, emax = a[:extrema] expand_extrema!(ex, vi)
a[:extrema] = (min(minimum(v), emin), max(maximum(v), emax))
end end
a[:extrema] ex
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."

View File

@ -2,48 +2,48 @@
defaultOutputFormat(plt::Plot) = "png" defaultOutputFormat(plt::Plot) = "png"
function png(plt::Plot, fn::@compat(AbstractString)) function png(plt::Plot, fn::@compat(String))
fn = addExtension(fn, "png") fn = addExtension(fn, "png")
io = open(fn, "w") io = open(fn, "w")
writemime(io, MIME("image/png"), plt) writemime(io, MIME("image/png"), plt)
close(io) close(io)
end end
png(fn::@compat(AbstractString)) = png(current(), fn) png(fn::@compat(String)) = png(current(), fn)
function svg(plt::Plot, fn::@compat(AbstractString)) function svg(plt::Plot, fn::@compat(String))
fn = addExtension(fn, "svg") fn = addExtension(fn, "svg")
io = open(fn, "w") io = open(fn, "w")
writemime(io, MIME("image/svg+xml"), plt) writemime(io, MIME("image/svg+xml"), plt)
close(io) close(io)
end end
svg(fn::@compat(AbstractString)) = svg(current(), fn) svg(fn::@compat(String)) = svg(current(), fn)
function pdf(plt::Plot, fn::@compat(AbstractString)) function pdf(plt::Plot, fn::@compat(String))
fn = addExtension(fn, "pdf") fn = addExtension(fn, "pdf")
io = open(fn, "w") io = open(fn, "w")
writemime(io, MIME("application/pdf"), plt) writemime(io, MIME("application/pdf"), plt)
close(io) close(io)
end end
pdf(fn::@compat(AbstractString)) = pdf(current(), fn) pdf(fn::@compat(String)) = pdf(current(), fn)
function ps(plt::Plot, fn::@compat(AbstractString)) function ps(plt::Plot, fn::@compat(String))
fn = addExtension(fn, "ps") fn = addExtension(fn, "ps")
io = open(fn, "w") io = open(fn, "w")
writemime(io, MIME("application/postscript"), plt) writemime(io, MIME("application/postscript"), plt)
close(io) close(io)
end end
ps(fn::@compat(AbstractString)) = ps(current(), fn) ps(fn::@compat(String)) = ps(current(), fn)
function tex(plt::Plot, fn::@compat(AbstractString)) function tex(plt::Plot, fn::@compat(String))
fn = addExtension(fn, "tex") fn = addExtension(fn, "tex")
io = open(fn, "w") io = open(fn, "w")
writemime(io, MIME("application/x-tex"), plt) writemime(io, MIME("application/x-tex"), plt)
close(io) close(io)
end end
tex(fn::@compat(AbstractString)) = tex(current(), fn) tex(fn::@compat(String)) = tex(current(), fn)
# ---------------------------------------------------------------- # ----------------------------------------------------------------
@ -57,7 +57,7 @@ tex(fn::@compat(AbstractString)) = tex(current(), fn)
"tex" => tex, "tex" => tex,
) )
function getExtension(fn::@compat(AbstractString)) function getExtension(fn::@compat(String))
pieces = split(fn, ".") pieces = split(fn, ".")
length(pieces) > 1 || error("Can't extract file extension: ", fn) length(pieces) > 1 || error("Can't extract file extension: ", fn)
ext = pieces[end] ext = pieces[end]
@ -65,7 +65,7 @@ function getExtension(fn::@compat(AbstractString))
ext ext
end end
function addExtension(fn::@compat(AbstractString), ext::@compat(AbstractString)) function addExtension(fn::@compat(String), ext::@compat(String))
try try
oldext = getExtension(fn) oldext = getExtension(fn)
if oldext == ext if oldext == ext
@ -78,7 +78,7 @@ function addExtension(fn::@compat(AbstractString), ext::@compat(AbstractString))
end end
end end
function savefig(plt::Plot, fn::@compat(AbstractString)) function savefig(plt::Plot, fn::@compat(String))
# get the extension # get the extension
local ext local ext
@ -96,7 +96,7 @@ function savefig(plt::Plot, fn::@compat(AbstractString))
end end
func(plt, fn) func(plt, fn)
end end
savefig(fn::@compat(AbstractString)) = savefig(current(), fn) savefig(fn::@compat(String)) = savefig(current(), fn)
# --------------------------------------------------------- # ---------------------------------------------------------
@ -128,7 +128,7 @@ const _best_html_output_type = KW(
# a backup for html... passes to svg or png depending on the html_output_format arg # a backup for html... passes to svg or png depending on the html_output_format arg
function Base.writemime(io::IO, ::MIME"text/html", plt::Plot) function Base.writemime(io::IO, ::MIME"text/html", plt::Plot)
output_type = symbol(plt.attr[:html_output_format]) output_type = Symbol(plt.attr[:html_output_format])
if output_type == :auto if output_type == :auto
output_type = get(_best_html_output_type, backend_name(plt.backend), :svg) output_type = get(_best_html_output_type, backend_name(plt.backend), :svg)
end end
@ -171,7 +171,7 @@ end
# IJulia # IJulia
# --------------------------------------------------------- # ---------------------------------------------------------
const _ijulia_output = ASCIIString["text/html"] const _ijulia_output = @compat(String)["text/html"]
function setup_ijulia() function setup_ijulia()
# override IJulia inline display # override IJulia inline display
@ -179,18 +179,18 @@ function setup_ijulia()
@eval begin @eval begin
import IJulia import IJulia
export set_ijulia_output export set_ijulia_output
function set_ijulia_output(mimestr::ASCIIString) function set_ijulia_output(mimestr::@compat(String))
# info("Setting IJulia output format to $mimestr") # info("Setting IJulia output format to $mimestr")
global _ijulia_output global _ijulia_output
_ijulia_output[1] = mimestr _ijulia_output[1] = mimestr
end end
function IJulia.display_dict(plt::Plot) function IJulia.display_dict(plt::Plot)
global _ijulia_output global _ijulia_output
Dict{ASCIIString, ByteString}(_ijulia_output[1] => sprint(writemime, _ijulia_output[1], plt)) Dict{@compat(String), ByteString}(_ijulia_output[1] => sprint(writemime, _ijulia_output[1], plt))
end end
end end
# IJulia.display_dict(plt::Plot) = Dict{ASCIIString, ByteString}("text/html" => sprint(writemime, "text/html", plt)) # IJulia.display_dict(plt::Plot) = Dict{@compat(String), ByteString}("text/html" => sprint(writemime, "text/html", plt))
set_ijulia_output("text/html") set_ijulia_output("text/html")
end end
end end

View File

@ -199,7 +199,7 @@ end
function strip_first_letter(s::Symbol) function strip_first_letter(s::Symbol)
str = string(s) str = string(s)
str[1:1], symbol(str[2:end]) str[1:1], Symbol(str[2:end])
end end
@ -231,7 +231,7 @@ function _apply_series_recipe(plt::Plot, d::KW)
if st != :image if st != :image
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
data = d[letter] data = d[letter]
axis = sp.attr[symbol(letter, "axis")] axis = sp.attr[Symbol(letter, "axis")]
if eltype(data) <: Number if eltype(data) <: Number
expand_extrema!(axis, data) expand_extrema!(axis, data)
elseif isa(data, Surface) && eltype(data.surf) <: Number elseif isa(data, Surface) && eltype(data.surf) <: Number
@ -241,7 +241,7 @@ function _apply_series_recipe(plt::Plot, d::KW)
# as well as any coord offset (think of boxplot shape coords... they all # as well as any coord offset (think of boxplot shape coords... they all
# correspond to the same x-value) # correspond to the same x-value)
# @show letter,eltype(data),typeof(data) # @show letter,eltype(data),typeof(data)
d[letter], d[symbol(letter,"_discrete_indices")] = discrete_value!(axis, data) d[letter], d[Symbol(letter,"_discrete_indices")] = discrete_value!(axis, data)
end end
end end
end end
@ -501,8 +501,8 @@ end
# # TODO: remove?? this is the old way of handling discrete data... should be # # TODO: remove?? this is the old way of handling discrete data... should be
# # replaced by the Axis type and logic # # replaced by the Axis type and logic
# function setTicksFromStringVector(plt::Plot, d::KW, di::KW, letter) # function setTicksFromStringVector(plt::Plot, d::KW, di::KW, letter)
# sym = symbol(letter) # sym = Symbol(letter)
# ticksym = symbol(letter * "ticks") # ticksym = Symbol(letter * "ticks")
# pargs = plt.attr # pargs = plt.attr
# v = di[sym] # v = di[sym]
# #
@ -534,7 +534,7 @@ end
# plt.attr[ticksym] = ticks, labels # plt.attr[ticksym] = ticks, labels
# #
# # add an origsym field so that later on we can re-compute the x vector if ticks change # # add an origsym field so that later on we can re-compute the x vector if ticks change
# origsym = symbol(letter * "orig") # origsym = Symbol(letter * "orig")
# di[origsym] = v # di[origsym] = v
# di[sym] = get_indices(v, labels) # di[sym] = get_indices(v, labels)
# #

View File

@ -28,8 +28,8 @@ macro userplot(expr::Expr)
end end
typename = expr.args[2] typename = expr.args[2]
funcname = symbol(lowercase(string(typename))) funcname = Symbol(lowercase(string(typename)))
funcname2 = symbol(funcname, "!") funcname2 = Symbol(funcname, "!")
# @show typename funcname expr # @show typename funcname expr
# return a code block with the type definition and convenience plotting methods # return a code block with the type definition and convenience plotting methods
@ -81,7 +81,7 @@ if is_installed("DataFrames")
function handle_dfs(df::DataFrames.AbstractDataFrame, d::KW, letter, dfs::DFS) function handle_dfs(df::DataFrames.AbstractDataFrame, d::KW, letter, dfs::DFS)
if isa(dfs, Symbol) if isa(dfs, Symbol)
get!(d, symbol(letter * "guide"), string(dfs)) get!(d, Symbol(letter * "guide"), string(dfs))
collect(df[dfs]) collect(df[dfs])
else else
get!(d, :label, reshape(dfs, 1, length(dfs))) get!(d, :label, reshape(dfs, 1, length(dfs)))
@ -135,10 +135,10 @@ end
# expr.args[1].head == :(-->) # expr.args[1].head == :(-->)
# end # end
# #
# function _equals_symbol(arg::Symbol, sym::Symbol) # function _equals_Symbol(arg::Symbol, sym::Symbol)
# arg == sym # arg == sym
# end # end
# function _equals_symbol(arg::Expr, sym::Symbol) # function _equals_Symbol(arg::Expr, sym::Symbol)
# arg.head == :quote && arg.args[1] == sym # arg.head == :quote && arg.args[1] == sym
# end # end
# #
@ -152,11 +152,11 @@ end
# quiet, require, force = false, false, false # quiet, require, force = false, false, false
# if _is_arrow_tuple(e) # if _is_arrow_tuple(e)
# for flag in e.args # for flag in e.args
# if _equals_symbol(flag, :quiet) # if _equals_Symbol(flag, :quiet)
# quiet = true # quiet = true
# elseif _equals_symbol(flag, :require) # elseif _equals_Symbol(flag, :require)
# require = true # require = true
# elseif _equals_symbol(flag, :force) # elseif _equals_Symbol(flag, :force)
# force = true # force = true
# end # end
# end # end

View File

@ -476,7 +476,7 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
# #
# function handle_dfs(df::DataFrames.AbstractDataFrame, d::KW, letter, dfs::DFS) # function handle_dfs(df::DataFrames.AbstractDataFrame, d::KW, letter, dfs::DFS)
# if isa(dfs, Symbol) # if isa(dfs, Symbol)
# get!(d, symbol(letter * "label"), string(dfs)) # get!(d, Symbol(letter * "label"), string(dfs))
# collect(df[dfs]) # collect(df[dfs])
# else # else
# get!(d, :label, reshape(dfs, 1, length(dfs))) # get!(d, :label, reshape(dfs, 1, length(dfs)))

View File

@ -274,8 +274,8 @@ limsType{T<:Real,S<:Real}(lims::@compat(Tuple{T,S})) = :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{T<:Real}(::Type{Vector{T}}, rng::Range{T}) = 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{T<:Real,S<:Real}(::Type{Vector{T}}, rng::Range{S}) = T[x for x in rng]