working on 0.5 changes -- String
This commit is contained in:
parent
0a86ccb142
commit
3cc9425219
20
src/Plots.jl
20
src/Plots.jl
@ -285,9 +285,9 @@ plot3d!(args...; kw...) = plot!(args...; kw..., seriestype = :path3d)
|
||||
# quiver!(args...; kw...) = plot!(args...; kw..., seriestype = :quiver)
|
||||
|
||||
|
||||
title!(s::@compat(String); kw...) = plot!(; title = s, kw...)
|
||||
xlabel!(s::@compat(String); kw...) = plot!(; xlabel = s, kw...)
|
||||
ylabel!(s::@compat(String); kw...) = plot!(; ylabel = s, kw...)
|
||||
title!(s::AbstractString; kw...) = plot!(; title = s, kw...)
|
||||
xlabel!(s::AbstractString; kw...) = plot!(; xlabel = s, kw...)
|
||||
ylabel!(s::AbstractString; kw...) = plot!(; ylabel = s, 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...)
|
||||
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...)
|
||||
xticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; xticks = v, kw...)
|
||||
yticks!{T<:Real}(v::AVec{T}; kw...) = plot!(; yticks = v, kw...)
|
||||
xticks!{T<:Real,S<:@compat(String)}(
|
||||
xticks!{T<:Real,S<:AbstractString}(
|
||||
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; xticks = (ticks,labels), kw...)
|
||||
yticks!{T<:Real,S<:@compat(String)}(
|
||||
yticks!{T<:Real,S<:AbstractString}(
|
||||
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(; yticks = (ticks,labels), kw...)
|
||||
annotate!(anns...; 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...)
|
||||
yaxis!(args...; kw...) = plot!(; yaxis = args, kw...)
|
||||
|
||||
title!(plt::Plot, s::@compat(String); kw...) = plot!(plt; title = s, kw...)
|
||||
xlabel!(plt::Plot, s::@compat(String); kw...) = plot!(plt; xlabel = s, kw...)
|
||||
ylabel!(plt::Plot, s::@compat(String); kw...) = plot!(plt; ylabel = s, kw...)
|
||||
title!(plt::Plot, s::AbstractString; kw...) = plot!(plt; title = s, kw...)
|
||||
xlabel!(plt::Plot, s::AbstractString; kw...) = plot!(plt; xlabel = s, kw...)
|
||||
ylabel!(plt::Plot, s::AbstractString; kw...) = plot!(plt; ylabel = s, 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...)
|
||||
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...)
|
||||
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...)
|
||||
xticks!{T<:Real,S<:@compat(String)}(plt::Plot,
|
||||
xticks!{T<:Real,S<:AbstractString}(plt::Plot,
|
||||
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; xticks = (ticks,labels), kw...)
|
||||
yticks!{T<:Real,S<:@compat(String)}(plt::Plot,
|
||||
yticks!{T<:Real,S<:AbstractString}(plt::Plot,
|
||||
ticks::AVec{T}, labels::AVec{S}; kw...) = plot!(plt; yticks = (ticks,labels), 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...)
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
|
||||
immutable Animation
|
||||
dir::@compat(String)
|
||||
frames::Vector{@compat(String)}
|
||||
dir::Compat.ASCIIString
|
||||
frames::Vector{Compat.ASCIIString}
|
||||
end
|
||||
|
||||
function Animation()
|
||||
tmpdir = convert(@compat(String), mktempdir())
|
||||
Animation(tmpdir, @compat(String)[])
|
||||
tmpdir = convert(Compat.ASCIIString, mktempdir())
|
||||
Animation(tmpdir, Compat.ASCIIString[])
|
||||
end
|
||||
|
||||
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"
|
||||
immutable AnimatedGif
|
||||
filename::@compat(String)
|
||||
filename::Compat.ASCIIString
|
||||
end
|
||||
|
||||
function gif(anim::Animation, fn::@compat(String) = "tmp.gif"; fps::Integer = 20)
|
||||
function gif(anim::Animation, fn::Compat.ASCIIString = "tmp.gif"; fps::Integer = 20)
|
||||
fn = abspath(fn)
|
||||
|
||||
try
|
||||
|
||||
@ -678,8 +678,8 @@ end
|
||||
|
||||
"A special type that will break up incoming data into groups, and allow for easier creation of grouped plots"
|
||||
type GroupBy
|
||||
groupLabels::Vector{@compat(String)} # length == numGroups
|
||||
groupIds::Vector{Vector{Int}} # list of indices for each group
|
||||
groupLabels::Vector # length == numGroups
|
||||
groupIds::Vector{Vector{Int}} # list of indices for each group
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ function process_axis_arg!(d::KW, arg, letter = "")
|
||||
elseif arg in (:flip, :invert, :inverted)
|
||||
d[Symbol(letter,:flip)] = true
|
||||
|
||||
elseif T <: @compat(String)
|
||||
elseif T <: AbstractString
|
||||
d[Symbol(letter,:guide)] = arg
|
||||
|
||||
# xlims/ylims
|
||||
|
||||
@ -158,7 +158,7 @@ function plotlyfont(font::Font, color = font.color)
|
||||
)
|
||||
end
|
||||
|
||||
function get_annotation_dict(x, y, val::Union{@compat(String),Symbol})
|
||||
function get_annotation_dict(x, y, val)
|
||||
KW(
|
||||
:text => val,
|
||||
:xref => "x",
|
||||
|
||||
@ -196,7 +196,7 @@ function getPyPlotMarker(markers::AVec)
|
||||
end
|
||||
|
||||
# pass through
|
||||
function getPyPlotMarker(marker::@compat(String))
|
||||
function getPyPlotMarker(marker::AbstractString)
|
||||
@assert length(marker) == 1
|
||||
marker
|
||||
end
|
||||
@ -1096,7 +1096,7 @@ end
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
function createPyPlotAnnotationObject(sp::Subplot{PyPlotBackend}, x, y, val::@compat(String))
|
||||
function createPyPlotAnnotationObject(sp::Subplot{PyPlotBackend}, x, y, val)
|
||||
ax = sp.o
|
||||
ax[:annotate](val, xy = (x,y))
|
||||
end
|
||||
|
||||
@ -280,7 +280,7 @@ end
|
||||
# -------------------------------
|
||||
|
||||
# since this is such a hack, it's only callable using `png`... should error during normal `writemime`
|
||||
function png(plt::AbstractPlot{UnicodePlotsBackend}, fn::@compat(String))
|
||||
function png(plt::AbstractPlot{UnicodePlotsBackend}, fn::AbstractString)
|
||||
fn = addExtension(fn, "png")
|
||||
|
||||
# make some whitespace and show the plot
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
# CREDIT: parts of this implementation were inspired by @joshday's PlotlyLocal.jl
|
||||
|
||||
|
||||
function standalone_html(plt::AbstractPlot; title::@compat(String) = get(plt.attr, :window_title, "Plots.jl"))
|
||||
function standalone_html(plt::AbstractPlot; title::AbstractString = get(plt.attr, :window_title, "Plots.jl"))
|
||||
"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@ -19,7 +19,7 @@ function standalone_html(plt::AbstractPlot; title::@compat(String) = get(plt.att
|
||||
"""
|
||||
end
|
||||
|
||||
function open_browser_window(filename::@compat(String))
|
||||
function open_browser_window(filename::AbstractString)
|
||||
@osx_only return run(`open $(filename)`)
|
||||
@linux_only return run(`xdg-open $(filename)`)
|
||||
@windows_only return run(`$(ENV["COMSPEC"]) /c start $(filename)`)
|
||||
|
||||
@ -18,7 +18,8 @@ colorscheme(c::Colorant; kw...) = ColorWrapper(c; kw...)
|
||||
# --------------------------------------------------------------
|
||||
|
||||
|
||||
convertColor(c::@compat(Union{@compat(String), Symbol})) = parse(Colorant, string(c))
|
||||
convertColor(c::AbstractString) = parse(Colorant, c)
|
||||
convertColor(c::Symbol) = parse(Colorant, string(c))
|
||||
convertColor(c::Colorant) = c
|
||||
convertColor(cvec::AbstractVector) = map(convertColor, cvec)
|
||||
convertColor(c::ColorScheme) = c
|
||||
|
||||
@ -196,7 +196,7 @@ end
|
||||
|
||||
|
||||
immutable Font
|
||||
family::@compat(String)
|
||||
family::AbstractString
|
||||
pointsize::Int
|
||||
halign::Symbol
|
||||
valign::Symbol
|
||||
@ -227,7 +227,7 @@ function font(args...)
|
||||
valign = arg
|
||||
elseif T <: Colorant
|
||||
color = arg
|
||||
elseif T <: @compat Union{Symbol,@compat(String)}
|
||||
elseif T <: Symbol || T <: AbstractString
|
||||
try
|
||||
color = parse(Colorant, string(arg))
|
||||
catch
|
||||
@ -247,7 +247,7 @@ end
|
||||
|
||||
"Wrap a string with font info"
|
||||
immutable PlotText
|
||||
str::@compat(String)
|
||||
str::AbstractString
|
||||
font::Font
|
||||
end
|
||||
PlotText(str) = PlotText(string(str), font())
|
||||
@ -287,7 +287,7 @@ function stroke(args...; alpha = nothing)
|
||||
style = arg
|
||||
elseif T <: Colorant
|
||||
color = arg
|
||||
elseif T <: @compat Union{Symbol,@compat(String)}
|
||||
elseif T <: Symbol || T <: AbstractString
|
||||
try
|
||||
color = parse(Colorant, string(arg))
|
||||
end
|
||||
@ -319,7 +319,7 @@ function brush(args...; alpha = nothing)
|
||||
|
||||
if T <: Colorant
|
||||
color = arg
|
||||
elseif T <: @compat Union{Symbol,@compat(String)}
|
||||
elseif T <: Symbol || T <: AbstractString
|
||||
try
|
||||
color = parse(Colorant, string(arg))
|
||||
end
|
||||
|
||||
@ -2,48 +2,48 @@
|
||||
|
||||
defaultOutputFormat(plt::Plot) = "png"
|
||||
|
||||
function png(plt::Plot, fn::@compat(String))
|
||||
function png(plt::Plot, fn::AbstractString)
|
||||
fn = addExtension(fn, "png")
|
||||
io = open(fn, "w")
|
||||
writemime(io, MIME("image/png"), plt)
|
||||
close(io)
|
||||
end
|
||||
png(fn::@compat(String)) = png(current(), fn)
|
||||
png(fn::AbstractString) = png(current(), fn)
|
||||
|
||||
function svg(plt::Plot, fn::@compat(String))
|
||||
function svg(plt::Plot, fn::AbstractString)
|
||||
fn = addExtension(fn, "svg")
|
||||
io = open(fn, "w")
|
||||
writemime(io, MIME("image/svg+xml"), plt)
|
||||
close(io)
|
||||
end
|
||||
svg(fn::@compat(String)) = svg(current(), fn)
|
||||
svg(fn::AbstractString) = svg(current(), fn)
|
||||
|
||||
|
||||
function pdf(plt::Plot, fn::@compat(String))
|
||||
function pdf(plt::Plot, fn::AbstractString)
|
||||
fn = addExtension(fn, "pdf")
|
||||
io = open(fn, "w")
|
||||
writemime(io, MIME("application/pdf"), plt)
|
||||
close(io)
|
||||
end
|
||||
pdf(fn::@compat(String)) = pdf(current(), fn)
|
||||
pdf(fn::AbstractString) = pdf(current(), fn)
|
||||
|
||||
|
||||
function ps(plt::Plot, fn::@compat(String))
|
||||
function ps(plt::Plot, fn::AbstractString)
|
||||
fn = addExtension(fn, "ps")
|
||||
io = open(fn, "w")
|
||||
writemime(io, MIME("application/postscript"), plt)
|
||||
close(io)
|
||||
end
|
||||
ps(fn::@compat(String)) = ps(current(), fn)
|
||||
ps(fn::AbstractString) = ps(current(), fn)
|
||||
|
||||
|
||||
function tex(plt::Plot, fn::@compat(String))
|
||||
function tex(plt::Plot, fn::AbstractString)
|
||||
fn = addExtension(fn, "tex")
|
||||
io = open(fn, "w")
|
||||
writemime(io, MIME("application/x-tex"), plt)
|
||||
close(io)
|
||||
end
|
||||
tex(fn::@compat(String)) = tex(current(), fn)
|
||||
tex(fn::AbstractString) = tex(current(), fn)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
@ -57,7 +57,7 @@ tex(fn::@compat(String)) = tex(current(), fn)
|
||||
"tex" => tex,
|
||||
)
|
||||
|
||||
function getExtension(fn::@compat(String))
|
||||
function getExtension(fn::AbstractString)
|
||||
pieces = split(fn, ".")
|
||||
length(pieces) > 1 || error("Can't extract file extension: ", fn)
|
||||
ext = pieces[end]
|
||||
@ -65,7 +65,7 @@ function getExtension(fn::@compat(String))
|
||||
ext
|
||||
end
|
||||
|
||||
function addExtension(fn::@compat(String), ext::@compat(String))
|
||||
function addExtension(fn::AbstractString, ext::AbstractString)
|
||||
try
|
||||
oldext = getExtension(fn)
|
||||
if oldext == ext
|
||||
@ -78,7 +78,7 @@ function addExtension(fn::@compat(String), ext::@compat(String))
|
||||
end
|
||||
end
|
||||
|
||||
function savefig(plt::Plot, fn::@compat(String))
|
||||
function savefig(plt::Plot, fn::AbstractString)
|
||||
|
||||
# get the extension
|
||||
local ext
|
||||
@ -96,7 +96,7 @@ function savefig(plt::Plot, fn::@compat(String))
|
||||
end
|
||||
func(plt, fn)
|
||||
end
|
||||
savefig(fn::@compat(String)) = savefig(current(), fn)
|
||||
savefig(fn::AbstractString) = savefig(current(), fn)
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
@ -171,7 +171,7 @@ end
|
||||
# IJulia
|
||||
# ---------------------------------------------------------
|
||||
|
||||
const _ijulia_output = @compat(String)["text/html"]
|
||||
const _ijulia_output = Compat.ASCIIString["text/html"]
|
||||
|
||||
function setup_ijulia()
|
||||
# override IJulia inline display
|
||||
@ -179,18 +179,16 @@ function setup_ijulia()
|
||||
@eval begin
|
||||
import IJulia
|
||||
export set_ijulia_output
|
||||
function set_ijulia_output(mimestr::@compat(String))
|
||||
function set_ijulia_output(mimestr::AbstractString)
|
||||
# info("Setting IJulia output format to $mimestr")
|
||||
global _ijulia_output
|
||||
_ijulia_output[1] = mimestr
|
||||
end
|
||||
function IJulia.display_dict(plt::Plot)
|
||||
global _ijulia_output
|
||||
Dict{@compat(String), ByteString}(_ijulia_output[1] => sprint(writemime, _ijulia_output[1], plt))
|
||||
Dict{Compat.ASCIIString, ByteString}(_ijulia_output[1] => sprint(writemime, _ijulia_output[1], plt))
|
||||
end
|
||||
end
|
||||
|
||||
# IJulia.display_dict(plt::Plot) = Dict{@compat(String), ByteString}("text/html" => sprint(writemime, "text/html", plt))
|
||||
set_ijulia_output("text/html")
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user