Skip to content

annotate! with splatted arguments does not work #2487

@harryscholes

Description

@harryscholes

According to:

annotate!(anns...; kw...) = plot!(; annotation = anns, kw...)

I would expect the following to work:

julia> using Plots

julia> plot(1:10)

julia> annotate!((7,3,"(7,3)"), (3,7,text("hey", 14, :left, :top, :green)))
ERROR: MethodError: no method matching process_annotation(::Plots.Subplot{Plots.GRBackend}, ::Tuple{Int64,Int64,String}, ::Tuple{Int64,Int64,Plots.PlotText})
Closest candidates are:
  process_annotation(::Plots.Subplot, ::Any, ::Any, ::Any) at /Users/harry/.julia/packages/Plots/FQOz1/src/components.jl:592
  process_annotation(::Plots.Subplot, ::Any, ::Any, ::Any, ::Any) at /Users/harry/.julia/packages/Plots/FQOz1/src/components.jl:592
  process_annotation(::Plots.Subplot, ::Union{AbstractArray{Symbol,1}, Symbol}, ::Any) at /Users/harry/.julia/packages/Plots/FQOz1/src/components.jl:606
  ...
Stacktrace:
 [1] _update_subplot_periphery(::Plots.Subplot{Plots.GRBackend}, ::Array{Any,1}) at /Users/harry/.julia/packages/Plots/FQOz1/src/args.jl:1399
 [2] _update_subplot_args(::Plots.Plot{Plots.GRBackend}, ::Plots.Subplot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Int64, ::Bool) at /Users/harry/.julia/packages/Plots/FQOz1/src/args.jl:1502
 [3] _subplot_setup(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}) at /Users/harry/.julia/packages/Plots/FQOz1/src/pipeline.jl:297
 [4] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{}) at /Users/harry/.julia/packages/Plots/FQOz1/src/plot.jl:206
 [5] #plot!#138(::Base.Iterators.Pairs{Symbol,Tuple{Tuple{Int64,Int64,String},Tuple{Int64,Int64,Plots.PlotText}},Tuple{Symbol},NamedTuple{(:annotation,),Tuple{Tuple{Tuple{Int64,Int64,String},Tuple{Int64,Int64,Plots.PlotText}}}}}, ::typeof(plot!), ::Plots.Plot{Plots.GRBackend}) at /Users/harry/.julia/packages/Plots/FQOz1/src/plot.jl:158
 [6] (::RecipesBase.var"#kw##plot!")(::NamedTuple{(:annotation,),Tuple{Tuple{Tuple{Int64,Int64,String},Tuple{Int64,Int64,Plots.PlotText}}}}, ::typeof(plot!), ::Plots.Plot{Plots.GRBackend}) at ./none:0
 [7] #plot!#137(::Base.Iterators.Pairs{Symbol,Tuple{Tuple{Int64,Int64,String},Tuple{Int64,Int64,Plots.PlotText}},Tuple{Symbol},NamedTuple{(:annotation,),Tuple{Tuple{Tuple{Int64,Int64,String},Tuple{Int64,Int64,Plots.PlotText}}}}}, ::typeof(plot!)) at /Users/harry/.julia/packages/Plots/FQOz1/src/plot.jl:150
 [8] (::RecipesBase.var"#kw##plot!")(::NamedTuple{(:annotation,),Tuple{Tuple{Tuple{Int64,Int64,String},Tuple{Int64,Int64,Plots.PlotText}}}}, ::typeof(plot!)) at ./none:0
 [9] #annotate!#443 at /Users/harry/.julia/packages/Plots/FQOz1/src/shorthands.jl:440 [inlined]
 [10] annotate!(::Tuple{Int64,Int64,String}, ::Tuple{Int64,Int64,Plots.PlotText}) at /Users/harry/.julia/packages/Plots/FQOz1/src/shorthands.jl:440
 [11] top-level scope at none:0

I can't figure out why this doesn't work from the code in shorthands.jl though.

#2485

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions