I did some workaround before to achieve wonderful subplots in Julia Plotly, but currently struggling with a more complex problem. There are three ways below that should do the job. draw1 does it perfectly, but not applicable in my situation, draw2 does not, draw3 does in the REPL but otherwise not.
Here is the expected matrix of graphs aka subplots. expected matrix of graphs
draw1 does the job -> expected matrix of graphs appears
function draw1()
[plot([1,1,1]) plot([2,2,2]); plot([3,3,3]) plot([4,4,4])]
end
draw2a and draw2b do not, regardless of being called as a function of a module or copied into the REPL
function draw2a()
local mx = [1 2; 3 4]
local p(i) = plot([i,i,i])
p.(mx)
end
function draw2b()
local mx = [1 2; 3 4]
local p = map(i-> plot([i,i,i]), collect(1:4))
p[mx]
end
REPL does the same for draw2a and draw2b:
julia> subplots.draw2()
2×2 Array{PlotlyJS.SyncPlot,2}:
SyncPlot(data: [
"scatter with fields type, x, and y"
]
...
followed by the content of the graphs
draw3 perfectly does the job if copied into the REPL but does not if called
function draw3()
local p(i) = plot([i,i,i])
eval(Meta.parse("[p(1) p(2); p(3) p(4)]"))
end
if called:
julia> subplots.draw3()
ERROR: UndefVarError: p not defined
it must be a scope issue