fix some deprecation warnings

This commit is contained in:
Daniel Schwabeneder 2018-07-04 20:56:13 +02:00
parent 96d97699a0
commit a7f2484d45
23 changed files with 94 additions and 92 deletions

View File

@ -1,4 +1,4 @@
julia 0.7 julia 0.7-alpha
RecipesBase 0.2.3 RecipesBase 0.2.3
PlotUtils 0.4.1 PlotUtils 0.4.1
@ -14,4 +14,3 @@ NaNMath
Requires Requires
Contour Contour
GR 0.31.0 GR 0.31.0
Dates

View File

@ -6,7 +6,7 @@ using Reexport
import StaticArrays import StaticArrays
using StaticArrays.FixedSizeArrays using StaticArrays.FixedSizeArrays
using Dates using Dates, Printf, Statistics, Base64
@reexport using RecipesBase @reexport using RecipesBase
import RecipesBase: plot, plot!, animate import RecipesBase: plot, plot!, animate
@ -265,29 +265,29 @@ xgrid!(args...; kw...) = plot!(; xgrid = args
ygrid!(args...; kw...) = plot!(; ygrid = args, kw...) ygrid!(args...; kw...) = plot!(; ygrid = args, kw...)
let PlotOrSubplot = Union{Plot, Subplot} let PlotOrSubplot = Union{Plot, Subplot}
title!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; title = s, kw...) global title!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; title = s, kw...)
xlabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; xlabel = s, kw...) global xlabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; xlabel = s, kw...)
ylabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; ylabel = s, kw...) global ylabel!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; ylabel = s, kw...)
xlims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; xlims = lims, kw...) global xlims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; xlims = lims, kw...)
ylims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; ylims = lims, kw...) global ylims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; ylims = lims, kw...)
zlims!(plt::PlotOrSubplot, lims::Tuple{T,S}; kw...) where {T<:Real,S<:Real} = plot!(plt; zlims = lims, kw...) global 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...) global 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...) global 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...) global zlims!(plt::PlotOrSubplot, zmin::Real, zmax::Real; kw...) = plot!(plt; zlims = (zmin,zmax), kw...)
xticks!(plt::PlotOrSubplot, ticks::AVec{T}; kw...) where {T<:Real} = plot!(plt; xticks = ticks, kw...) global xticks!(plt::PlotOrSubplot, ticks::AVec{T}; kw...) where {T<:Real} = plot!(plt; xticks = ticks, kw...)
yticks!(plt::PlotOrSubplot, ticks::AVec{T}; kw...) where {T<:Real} = plot!(plt; yticks = ticks, kw...) global yticks!(plt::PlotOrSubplot, ticks::AVec{T}; kw...) where {T<:Real} = plot!(plt; yticks = ticks, kw...)
xticks!(plt::PlotOrSubplot, global xticks!(plt::PlotOrSubplot,
ticks::AVec{T}, labels::AVec{S}; kw...) where {T<:Real,S<:AbstractString} = 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!(plt::PlotOrSubplot, global yticks!(plt::PlotOrSubplot,
ticks::AVec{T}, labels::AVec{S}; kw...) where {T<:Real,S<:AbstractString} = 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...) global xgrid!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xgrid = args, kw...)
ygrid!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; ygrid = args, kw...) global ygrid!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; ygrid = args, kw...)
annotate!(plt::PlotOrSubplot, anns...; kw...) = plot!(plt; annotation = anns, kw...) global annotate!(plt::PlotOrSubplot, anns...; kw...) = plot!(plt; annotation = anns, kw...)
annotate!(plt::PlotOrSubplot, anns::AVec{T}; kw...) where {T<:Tuple} = plot!(plt; annotation = anns, kw...) global 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...) global xflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; xflip = flip, kw...)
yflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; yflip = flip, kw...) global yflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; yflip = flip, kw...)
xaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xaxis = args, kw...) global xaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xaxis = args, kw...)
yaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; yaxis = args, kw...) global yaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; yaxis = args, kw...)
end end

View File

@ -15,7 +15,7 @@ function add_non_underscore_aliases!(aliases::Dict{Symbol,Symbol})
for (k,v) in aliases for (k,v) in aliases
s = string(k) s = string(k)
if '_' in s if '_' in s
aliases[Symbol(replace(s, "_", ""))] = v aliases[Symbol(replace(s, "_" => ""))] = v
end end
end end
end end
@ -176,7 +176,7 @@ const _positionAliases = Dict{Symbol,Symbol}(
const _allScales = [:identity, :ln, :log2, :log10, :asinh, :sqrt] const _allScales = [:identity, :ln, :log2, :log10, :asinh, :sqrt]
const _logScales = [:ln, :log2, :log10] const _logScales = [:ln, :log2, :log10]
const _logScaleBases = Dict(:ln => e, :log2 => 2.0, :log10 => 10.0) const _logScaleBases = Dict(:ln => , :log2 => 2.0, :log10 => 10.0)
const _scaleAliases = Dict{Symbol,Symbol}( const _scaleAliases = Dict{Symbol,Symbol}(
:none => :identity, :none => :identity,
:log => :log10, :log => :log10,
@ -192,7 +192,7 @@ hasgrid(arg::Nothing, letter) = false
hasgrid(arg::Bool, letter) = arg hasgrid(arg::Bool, letter) = arg
function hasgrid(arg::Symbol, letter) function hasgrid(arg::Symbol, letter)
if arg in _allGridSyms if arg in _allGridSyms
arg in (:all, :both, :on) || contains(string(arg), string(letter)) arg in (:all, :both, :on) || occursin(string(letter), string(arg))
else else
warn("Unknown grid argument $arg; $(Symbol(letter, :grid)) was set to `true` instead.") warn("Unknown grid argument $arg; $(Symbol(letter, :grid)) was set to `true` instead.")
true true
@ -210,7 +210,7 @@ showaxis(arg::Nothing, letter) = false
showaxis(arg::Bool, letter) = arg showaxis(arg::Bool, letter) = arg
function showaxis(arg::Symbol, letter) function showaxis(arg::Symbol, letter)
if arg in _allGridSyms if arg in _allGridSyms
arg in (:all, :both, :on, :yes) || contains(string(arg), string(letter)) arg in (:all, :both, :on, :yes) || occursin(string(letter), string(arg))
else else
warn("Unknown showaxis argument $arg; $(Symbol(letter, :showaxis)) was set to `true` instead.") warn("Unknown showaxis argument $arg; $(Symbol(letter, :showaxis)) was set to `true` instead.")
true true
@ -1029,7 +1029,7 @@ function extractGroupArgs(vs::Tuple, args...)
end end
# allow passing NamedTuples for a named legend entry # allow passing NamedTuples for a named legend entry
@require NamedTuples begin @require NamedTuples = "73a701b4-84e1-5df0-88ff-1968ee2ee8dc" begin
legendEntryFromTuple(ns::NamedTuples.NamedTuple) = legendEntryFromTuple(ns::NamedTuples.NamedTuple) =
join(["$k = $v" for (k, v) in zip(keys(ns), values(ns))], ", ") join(["$k = $v" for (k, v) in zip(keys(ns), values(ns))], ", ")

View File

@ -9,7 +9,7 @@ TODO
* fix units in all visuals (e.g dotted lines, marker scale, surfaces) * fix units in all visuals (e.g dotted lines, marker scale, surfaces)
=# =#
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "glvisualize.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "glvisualize.jl"))
end end
@ -1005,7 +1005,7 @@ end
function scale_for_annotations!(series::Series, scaletype::Symbol = :pixels) function scale_for_annotations!(series::Series, scaletype::Symbol = :pixels)
anns = series[:series_annotations] anns = series[:series_annotations]
if anns != nothing && !isnull(anns.baseshape) if anns != nothing && anns.baseshape != nothing
# we use baseshape to overwrite the markershape attribute # we use baseshape to overwrite the markershape attribute
# with a list of custom shapes for each # with a list of custom shapes for each
msw, msh = anns.scalefactor msw, msh = anns.scalefactor

View File

@ -3,7 +3,7 @@
# significant contributions by @jheinen # significant contributions by @jheinen
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "gr.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "gr.jl"))
end end
@ -196,7 +196,7 @@ gr_inqtext(x, y, s::Symbol) = gr_inqtext(x, y, string(s))
function gr_inqtext(x, y, s) function gr_inqtext(x, y, s)
if length(s) >= 2 && s[1] == '$' && s[end] == '$' if length(s) >= 2 && s[1] == '$' && s[end] == '$'
GR.inqtextext(x, y, s[2:end-1]) GR.inqtextext(x, y, s[2:end-1])
elseif search(s, '\\') != 0 || contains(s, "10^{") elseif something(findfirst(isequal('\\'), s), 0) != 0 || occursin("10^{", s)
GR.inqtextext(x, y, s) GR.inqtextext(x, y, s)
else else
GR.inqtext(x, y, s) GR.inqtext(x, y, s)
@ -208,7 +208,7 @@ gr_text(x, y, s::Symbol) = gr_text(x, y, string(s))
function gr_text(x, y, s) function gr_text(x, y, s)
if length(s) >= 2 && s[1] == '$' && s[end] == '$' if length(s) >= 2 && s[1] == '$' && s[end] == '$'
GR.mathtex(x, y, s[2:end-1]) GR.mathtex(x, y, s[2:end-1])
elseif search(s, '\\') != 0 || contains(s, "10^{") elseif something(findfirst(isequal('\\'), s), 0) != 0 || occursin("10^{", s)
GR.textext(x, y, s) GR.textext(x, y, s)
else else
GR.text(x, y, s) GR.text(x, y, s)
@ -502,16 +502,16 @@ function gr_legend_pos(s::Symbol,w,h)
if str == "best" if str == "best"
str = "topright" str = "topright"
end end
if contains(str,"right") if occursin("right", str)
xpos = viewport_plotarea[2] - 0.05 - w xpos = viewport_plotarea[2] - 0.05 - w
elseif contains(str,"left") elseif occursin("left", str)
xpos = viewport_plotarea[1] + 0.11 xpos = viewport_plotarea[1] + 0.11
else else
xpos = (viewport_plotarea[2]-viewport_plotarea[1])/2 - w/2 +.04 xpos = (viewport_plotarea[2]-viewport_plotarea[1])/2 - w/2 +.04
end end
if contains(str,"top") if occursin("top", str)
ypos = viewport_plotarea[4] - 0.06 ypos = viewport_plotarea[4] - 0.06
elseif contains(str,"bottom") elseif occursin("bottom", str)
ypos = viewport_plotarea[3] + h + 0.06 ypos = viewport_plotarea[3] + h + 0.06
else else
ypos = (viewport_plotarea[4]-viewport_plotarea[3])/2 + h/2 ypos = (viewport_plotarea[4]-viewport_plotarea[3])/2 + h/2
@ -1069,7 +1069,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if cmap if cmap
gr_set_line(1, :solid, yaxis[:foreground_color_axis]) gr_set_line(1, :solid, yaxis[:foreground_color_axis])
gr_set_viewport_cmap(sp) gr_set_viewport_cmap(sp)
l = (length(h) > 1) ? round.(Int32, 1000 + (h - ignorenan_minimum(h)) / (ignorenan_maximum(h) - ignorenan_minimum(h)) * 255) : Int32[1000, 1255] l = (length(h) > 1) ? round.(Int32, 1000 .+ (h .- ignorenan_minimum(h)) ./ (ignorenan_maximum(h) - ignorenan_minimum(h)) .* 255) : Int32[1000, 1255]
GR.setwindow(xmin, xmax, zmin, zmax) GR.setwindow(xmin, xmax, zmin, zmax)
GR.cellarray(xmin, xmax, zmax, zmin, 1, length(l), l) GR.cellarray(xmin, xmax, zmax, zmin, 1, length(l), l)
ztick = 0.5 * GR.tick(zmin, zmax) ztick = 0.5 * GR.tick(zmin, zmax)
@ -1358,10 +1358,10 @@ const _gr_mimeformats = Dict(
"image/svg+xml" => "svg", "image/svg+xml" => "svg",
) )
const _gr_wstype_default = @static if is_linux() const _gr_wstype_default = @static if Sys.islinux()
"x11" "x11"
# "cairox11" # "cairox11"
elseif is_apple() elseif Sys.isapple()
"quartz" "quartz"
else else
"use_default" "use_default"

View File

@ -28,7 +28,7 @@ Read from .hdf5 file using:
- Should be reliable for archival purposes. - Should be reliable for archival purposes.
==# ==#
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "hdf5.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "hdf5.jl"))
end end

View File

@ -13,7 +13,7 @@ Add in functionality to Plots.jl:
:aspect_ratio, :aspect_ratio,
=# =#
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "inspectdr.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "inspectdr.jl"))
end end

View File

@ -2,7 +2,7 @@
# significant contributions by: @pkofod # significant contributions by: @pkofod
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "pgfplots.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "pgfplots.jl"))
end end
@ -426,11 +426,12 @@ function pgf_axis(sp::Subplot, letter)
push!(style, string(letter, "tick = {", join(tick_values,","), "}")) push!(style, string(letter, "tick = {", join(tick_values,","), "}"))
if axis[:showaxis] && axis[:scale] in (:ln, :log2, :log10) && axis[:ticks] == :auto if axis[:showaxis] && axis[:scale] in (:ln, :log2, :log10) && axis[:ticks] == :auto
# wrap the power part of label with } # wrap the power part of label with }
tick_labels = String[begin tick_labels = Vector{String}(length(ticks[2]))
for (i, label) in enumerate(ticks[2])
base, power = split(label, "^") base, power = split(label, "^")
power = string("{", power, "}") power = string("{", power, "}")
string(base, "^", power) tick_labels[i] = string(base, "^", power)
end for label in ticks[2]] end
push!(style, string(letter, "ticklabels = {\$", join(tick_labels,"\$,\$"), "\$}")) push!(style, string(letter, "ticklabels = {\$", join(tick_labels,"\$,\$"), "\$}"))
elseif axis[:showaxis] elseif axis[:showaxis]
tick_labels = ispolar(sp) && letter == :x ? [ticks[2][3:end]..., "0", "45"] : ticks[2] tick_labels = ispolar(sp) && letter == :x ? [ticks[2][3:end]..., "0", "45"] : ticks[2]

View File

@ -1,7 +1,7 @@
# https://plot.ly/javascript/getting-started # https://plot.ly/javascript/getting-started
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "plotly.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "plotly.jl"))
end end

View File

@ -1,4 +1,4 @@
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "plotlyjs.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "plotlyjs.jl"))
end end
@ -120,7 +120,7 @@ function _display(plt::Plot{PlotlyJSBackend})
end end
end end
@require WebIO begin @require WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29" begin
function WebIO.render(plt::Plot{PlotlyJSBackend}) function WebIO.render(plt::Plot{PlotlyJSBackend})
prepare_output(plt) prepare_output(plt)
WebIO.render(plt.o) WebIO.render(plt.o)

View File

@ -1,7 +1,7 @@
# https://github.com/stevengj/PyPlot.jl # https://github.com/stevengj/PyPlot.jl
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "pyplot.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "pyplot.jl"))
end end
@ -679,8 +679,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
if typeof(z) <: AbstractMatrix || typeof(z) <: Surface if typeof(z) <: AbstractMatrix || typeof(z) <: Surface
x, y, z = map(Array, (x,y,z)) x, y, z = map(Array, (x,y,z))
if !ismatrix(x) || !ismatrix(y) if !ismatrix(x) || !ismatrix(y)
x = repmat(x', length(y), 1) x = repeat(x', length(y), 1)
y = repmat(y, 1, length(series[:x])) y = repeat(y, 1, length(series[:x]))
end end
z = transpose_z(series, z) z = transpose_z(series, z)
if st == :surface if st == :surface
@ -919,7 +919,7 @@ function py_set_scale(ax, axis::Axis)
"linear" "linear"
else else
kw[Symbol(:base,letter)] = if scale == :ln kw[Symbol(:base,letter)] = if scale == :ln
e
elseif scale == :log2 elseif scale == :log2
2 2
elseif scale == :log10 elseif scale == :log10

View File

@ -1,7 +1,7 @@
# https://github.com/Evizero/UnicodePlots.jl # https://github.com/Evizero/UnicodePlots.jl
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "unicodeplots.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "unicodeplots.jl"))
end end
@ -183,7 +183,7 @@ function png(plt::AbstractPlot{UnicodePlotsBackend}, fn::AbstractString)
gui(plt) gui(plt)
# @osx_only begin # @osx_only begin
@static if is_apple() @static if Sys.isapple()
# BEGIN HACK # BEGIN HACK
# wait while the plot gets drawn # wait while the plot gets drawn

View File

@ -2,7 +2,7 @@
# NOTE: backend should implement `html_body` and `html_head` # NOTE: backend should implement `html_body` and `html_head`
# CREDIT: parts of this implementation were inspired by @joshday's PlotlyLocal.jl # CREDIT: parts of this implementation were inspired by @joshday's PlotlyLocal.jl
@require Revise begin @require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" begin
Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "web.jl")) Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "web.jl"))
end end
@ -23,13 +23,13 @@ function standalone_html(plt::AbstractPlot; title::AbstractString = get(plt.attr
end end
function open_browser_window(filename::AbstractString) function open_browser_window(filename::AbstractString)
@static if is_apple() @static if Sys.isapple()
return run(`open $(filename)`) return run(`open $(filename)`)
end end
@static if is_linux() || is_bsd() # is_bsd() addition is as yet untested, but based on suggestion in https://github.com/JuliaPlots/Plots.jl/issues/681 @static if Sys.islinux() || is_bsd() # is_bsd() addition is as yet untested, but based on suggestion in https://github.com/JuliaPlots/Plots.jl/issues/681
return run(`xdg-open $(filename)`) return run(`xdg-open $(filename)`)
end end
@static if is_windows() @static if Sys.iswindows()
return run(`$(ENV["COMSPEC"]) /c start "" "$(filename)"`) return run(`$(ENV["COMSPEC"]) /c start "" "$(filename)"`)
end end
@warn("Unknown OS... cannot open browser window.") @warn("Unknown OS... cannot open browser window.")

View File

@ -486,12 +486,13 @@ function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
# end # end
# @show msw msh # @show msw msh
if anns != nothing && !isnull(anns.baseshape) if anns != nothing && anns.baseshape != nothing
# we use baseshape to overwrite the markershape attribute # we use baseshape to overwrite the markershape attribute
# with a list of custom shapes for each # with a list of custom shapes for each
msw,msh = anns.scalefactor msw,msh = anns.scalefactor
msize = Float64[] msize = Float64[]
shapes = Shape[begin shapes = Vector{Shape}(length(anns.strs))
for i in eachindex(anns.strs)
str = _cycle(anns.strs,i) str = _cycle(anns.strs,i)
# get the width and height of the string (in mm) # get the width and height of the string (in mm)
@ -509,8 +510,8 @@ function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
maxscale = max(xscale, yscale) maxscale = max(xscale, yscale)
push!(msize, maxscale) push!(msize, maxscale)
baseshape = _cycle(get(anns.baseshape),i) baseshape = _cycle(get(anns.baseshape),i)
shape = scale(baseshape, msw*xscale/maxscale, msh*yscale/maxscale, (0,0)) shapes[i] = scale(baseshape, msw*xscale/maxscale, msh*yscale/maxscale, (0,0))
end for i=1:length(anns.strs)] end
series[:markershape] = shapes series[:markershape] = shapes
series[:markersize] = msize series[:markersize] = msize
end end

View File

@ -157,7 +157,7 @@ PlotExample("Marker types",
markers = reshape(markers, 1, length(markers)) markers = reshape(markers, 1, length(markers))
n = length(markers) n = length(markers)
x = range(0, stop=10, length=n+2)[2:end-1] x = range(0, stop=10, length=n+2)[2:end-1]
y = repmat(reshape(reverse(x),1,:), n, 1) y = repeat(reshape(reverse(x),1,:), n, 1)
scatter(x, y, m=(8,:auto), lab=map(string,markers), bg=:linen, xlim=(0,10), ylim=(0,10)) scatter(x, y, m=(8,:auto), lab=map(string,markers), bg=:linen, xlim=(0,10), ylim=(0,10))
end)] end)]
), ),
@ -269,8 +269,8 @@ unfilled contour from a matrix.
x = 1:0.5:20 x = 1:0.5:20
y = 1:0.5:10 y = 1:0.5:10
f(x,y) = (3x+y^2)*abs(sin(x)+cos(y)) f(x,y) = (3x+y^2)*abs(sin(x)+cos(y))
X = repmat(reshape(x,1,:), length(y), 1) X = repeat(reshape(x,1,:), length(y), 1)
Y = repmat(y, 1, length(x)) Y = repeat(y, 1, length(x))
Z = map(f, X, Y) Z = map(f, X, Y)
p1 = contour(x, y, f, fill=true) p1 = contour(x, y, f, fill=true)
p2 = contour(x, y, Z) p2 = contour(x, y, Z)

View File

@ -268,7 +268,7 @@ function GridLayout(dims...;
widths = zeros(dims[2]), widths = zeros(dims[2]),
heights = zeros(dims[1]), heights = zeros(dims[1]),
kw...) kw...)
grid = Matrix{AbstractLayout}(dims...) grid = Matrix{AbstractLayout}(undef, dims...)
layout = GridLayout( layout = GridLayout(
parent, parent,
(20mm, 5mm, 2mm, 10mm), (20mm, 5mm, 2mm, 10mm),
@ -357,10 +357,10 @@ function update_child_bboxes!(layout::GridLayout, minimum_perimeter = [0mm,0mm,0
# get the max horizontal (left and right) padding over columns, # get the max horizontal (left and right) padding over columns,
# and max vertical (bottom and top) padding over rows # and max vertical (bottom and top) padding over rows
# TODO: add extra padding here # TODO: add extra padding here
pad_left = maximum(minpad_left, 1) pad_left = maximum(minpad_left, dims = 1)
pad_top = maximum(minpad_top, 2) pad_top = maximum(minpad_top, dims = 2)
pad_right = maximum(minpad_right, 1) pad_right = maximum(minpad_right, dims = 1)
pad_bottom = maximum(minpad_bottom, 2) pad_bottom = maximum(minpad_bottom, dims = 2)
# make sure the perimeter match the parent # make sure the perimeter match the parent
pad_left[1] = max(pad_left[1], minimum_perimeter[1]) pad_left[1] = max(pad_left[1], minimum_perimeter[1])

View File

@ -146,7 +146,8 @@ function Base.display(::PlotsDisplay, plt::Plot)
end end
# override the REPL display to open a gui window # override the REPL display to open a gui window
Base.display(::Base.REPL.REPLDisplay, ::MIME"text/plain", plt::Plot) = gui(plt) using REPL
Base.display(::REPL.REPLDisplay, ::MIME"text/plain", plt::Plot) = gui(plt)
_do_plot_show(plt, showval::Bool) = showval && gui(plt) _do_plot_show(plt, showval::Bool) = showval && gui(plt)
@ -254,7 +255,7 @@ end
# IJulia # IJulia
# --------------------------------------------------------- # ---------------------------------------------------------
@require IJulia begin @require IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" begin
if IJulia.inited if IJulia.inited
""" """
@ -310,7 +311,7 @@ end
# --------------------------------------------------------- # ---------------------------------------------------------
# Atom PlotPane # Atom PlotPane
# --------------------------------------------------------- # ---------------------------------------------------------
@require Juno begin @require Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d" begin
import Hiccup, Media import Hiccup, Media
if Juno.isactive() if Juno.isactive()

View File

@ -11,11 +11,13 @@ function _expand_seriestype_array(d::KW, args)
sts = get(d, :seriestype, :path) sts = get(d, :seriestype, :path)
if typeof(sts) <: AbstractArray if typeof(sts) <: AbstractArray
delete!(d, :seriestype) delete!(d, :seriestype)
RecipeData[begin rd = Vector{RecipeData}(size(sts, 1))
for r in 1:size(sts, 1)
dc = copy(d) dc = copy(d)
dc[:seriestype] = sts[r:r,:] dc[:seriestype] = sts[r:r,:]
RecipeData(dc, args) rd[i] = RecipeData(dc, args)
end for r=1:size(sts,1)] end
rd
else else
RecipeData[RecipeData(copy(d), args)] RecipeData[RecipeData(copy(d), args)]
end end

View File

@ -46,9 +46,8 @@ When you pass in matrices, it splits by columns. To see the list of available at
function, where `attr` is the symbol `:Series:`, `:Subplot:`, `:Plot` or `:Axis`. Pass any attribute to `plotattr` function, where `attr` is the symbol `:Series:`, `:Subplot:`, `:Plot` or `:Axis`. Pass any attribute to `plotattr`
as a String to look up its docstring; e.g. `plotattr("seriestype")`. as a String to look up its docstring; e.g. `plotattr("seriestype")`.
""" """
# this creates a new plot with args/kw and sets it to be the current plot
function plot(args...; kw...) function plot(args...; kw...)
# this creates a new plot with args/kw and sets it to be the current plot
d = KW(kw) d = KW(kw)
preprocessArgs!(d) preprocessArgs!(d)

View File

@ -80,7 +80,7 @@ end
@recipe function f(::Type{Val{:hline}}, x, y, z) @recipe function f(::Type{Val{:hline}}, x, y, z)
n = length(y) n = length(y)
newx = repmat(Float64[-1, 1, NaN], n) newx = repeat(Float64[-1, 1, NaN], n)
newy = vec(Float64[yi for i=1:3,yi=y]) newy = vec(Float64[yi for i=1:3,yi=y])
x := newx x := newx
y := newy y := newy
@ -92,7 +92,7 @@ end
@recipe function f(::Type{Val{:vline}}, x, y, z) @recipe function f(::Type{Val{:vline}}, x, y, z)
n = length(y) n = length(y)
newx = vec(Float64[yi for i=1:3,yi=y]) newx = vec(Float64[yi for i=1:3,yi=y])
newy = repmat(Float64[-1, 1, NaN], n) newy = repeat(Float64[-1, 1, NaN], n)
x := newx x := newx
y := newy y := newy
seriestype := :straightline seriestype := :straightline

View File

@ -93,7 +93,7 @@ _get_showtheme_args(thm::Symbol, func::Symbol) = thm, get(_color_functions, func
cfunc(RGB(def)) cfunc(RGB(def))
elseif eltype(def) <: Colorant elseif eltype(def) <: Colorant
cfunc.(RGB.(def)) cfunc.(RGB.(def))
elseif contains(string(arg), "color") elseif occursin("color", string(arg))
cfunc.(RGB.(plot_color.(def))) cfunc.(RGB.(plot_color.(def)))
else else
def def

View File

@ -344,7 +344,7 @@ function replaceAliases!(d::KW, aliases::Dict{Symbol,Symbol})
end end
end end
createSegments(z) = collect(repmat(reshape(z,1,:),2,1))[2:end] createSegments(z) = collect(repeat(reshape(z,1,:),2,1))[2:end]
Base.first(c::Colorant) = c Base.first(c::Colorant) = c
Base.first(x::Symbol) = x Base.first(x::Symbol) = x
@ -356,7 +356,7 @@ sortedkeys(d::Dict) = sort(collect(keys(d)))
const _scale_base = Dict{Symbol, Real}( const _scale_base = Dict{Symbol, Real}(
:log10 => 10, :log10 => 10,
:log2 => 2, :log2 => 2,
:ln => e, :ln => ,
) )
function _heatmap_edges(v::AVec) function _heatmap_edges(v::AVec)
@ -1139,9 +1139,9 @@ function convert_sci_unicode(label::AbstractString)
"×10" => "×10^{", "×10" => "×10^{",
) )
for key in keys(unicode_dict) for key in keys(unicode_dict)
label = replace(label, key, unicode_dict[key]) label = replace(label, key => unicode_dict[key])
end end
if contains(label, "10^{") if occursin("10^{", label)
label = string(label, "}") label = string(label, "}")
end end
label label

View File

@ -6,4 +6,3 @@ GR 0.31.0
RDatasets RDatasets
VisualRegressionTests VisualRegressionTests
UnicodePlots UnicodePlots
Test