JuliaPlots/Plots.jl

[BUG] Nested `plot` calls seem to cause bugs with axis linking

Open

#2,767 opened on Jun 8, 2020

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Julia (1,943 stars) (381 forks)batch import
buggood first issue

Description

Consider the following MWE:

plot(
    [
    plot(
        plot(rand(subdf)); 
        title = title
    ) 
    for (subdf, title) in zip(1:30, string.('A':('A' + 30)))
    ]...; 
    size = (2000, 2000),
    legend = :none, 
    link = :all
)

This produces the following error:


ERROR: KeyError: key :xaxis not found
Stacktrace:
[1] getindex
  @ /Applications/Julia-1.5.app/Contents/Resources/julia/bin/../share/julia/base/dict.jl:467 [inlined]

[2] #146(sp::Plots.GridLayout)
  @ Plots ./none:0

[3] iterate
  @ /Applications/Julia-1.5.app/Contents/Resources/julia/bin/../share/julia/base/generator.jl:47 [inlined]

[4] collect(itr::Base.Generator{Array{Any,1},Plots.var"#146#147"{Symbol}})
  @ Base /Applications/Julia-1.5.app/Contents/Resources/julia/bin/../share/julia/base/array.jl:688

[5] link_axes!(a::Array{AbstractLayout,2}, axissym::Symbol)
  @ Plots ~/.julia/dev/Plots/src/layouts.jl:762

[6] link_axes!(layout::Plots.GridLayout, link::Symbol)
  @ Plots ~/.julia/dev/Plots/src/layouts.jl:796

[7] #plot#123(kw::Base.Iterators.Pairs{Symbol,Any,NTuple{6,Symbol},NamedTuple{(:size, :tickfontsize, :titlefontsize, :legend, :link, :margin),Tuple{Tuple{Int64,Int64},Int64,Int64,Symbol,Symbol,Measures.Length{:mm,Float64}}}}, ::typeof(plot), plt1::Plots.Plot{Plots.GRBackend}, plts_tail::Plots.Plot{Plots.GRBackend})
  @ Plots ~/.julia/dev/Plots/src/plot.jl:108

[8] top-level scope
  @ REPL[59]:1

However,

plot(
    [
    plot(
        rand(subdf); 
        title = title
    ) 
    for (subdf, title) in zip(1:30, string.('A':('A' + 30)))
    ]...; 
    size = (2000, 2000),
    legend = :none, 
    link = :all
)

works as expected.

This looks like a bug in Plots.

Contributor guide