Skip to content

Commit ffbfd84

Browse files
committed
add mgrid helper function (used throughout docs)
1 parent ce6896f commit ffbfd84

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/PlotlyJS.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using Blink
2121
using Pkg.Artifacts
2222
using Requires
2323

24-
export plot, dataset, list_datasets, make_subplots, savefig
24+
export plot, dataset, list_datasets, make_subplots, savefig, mgrid
2525

2626
# globals for this package
2727
const _pkg_root = dirname(dirname(@__FILE__))

src/util.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,18 @@ function PlotlyBase.add_recession_bands!(p::SyncPlot; kwargs...)
1414
relayout!(p, shapes=new_shapes)
1515
new_shapes
1616
end
17+
18+
function mgrid(arrays...)
19+
lengths = collect(length.(arrays))
20+
uno = ones(Int, length(arrays))
21+
out = []
22+
for i in 1:length(arrays)
23+
repeats = copy(lengths)
24+
repeats[i] = 1
25+
26+
shape = copy(uno)
27+
shape[i] = lengths[i]
28+
push!(out, reshape(arrays[i], shape...) .* ones(repeats...))
29+
end
30+
out
31+
end

0 commit comments

Comments
 (0)