Skip to content

Commit 70fbc66

Browse files
committed
add layout kwargs
1 parent a1f66e0 commit 70fbc66

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ext/ZXCalculusExt.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ function generate_d_edges(zxd::ZXGraph)
4747
end
4848
return DataFrame(src=s, dst=d, isHadamard=isH)
4949
end
50-
generate_d_edges(zxd::ZXCircuit) = generate_d_edges(zxd.zx_graph)
50+
generate_d_edges(zxd::ZXCircuit) = generate_d_edges(base_zx_graph(zxd))
5151

5252
function ZXCalculus.ZX.plot(zxg::ZXGraph{T, P}; kwargs...) where {T, P}
5353
return ZXCalculus.ZX.plot(ZXCircuit(zxg); kwargs...)
5454
end
5555

5656
function ZXCalculus.ZX.plot(zxd::Union{ZXDiagram, ZXCircuit};
57+
layout::ZXCalculus.ZX.ZXLayout=ZXCalculus.ZX.generate_layout!(zxd),
5758
output_html::Union{String, Nothing}=nothing,
5859
open_browser::Bool=true,
5960
kwargs...)
6061
scale = 2
6162
lattice_unit = 50 * scale
62-
layout = ZXCalculus.ZX.generate_layout!(zxd)
6363
vs = spiders(zxd)
6464
x_locs = layout.spider_col
6565
x_min = minimum(values(x_locs), init=0)
@@ -83,6 +83,11 @@ function ZXCalculus.ZX.plot(zxd::Union{ZXDiagram, ZXCircuit};
8383

8484
d_spiders = generate_d_spiders(vs, st, ps, x_locs_normal, y_locs_normal)
8585
d_edges = generate_d_edges(zxd)
86+
sort!(d_spiders, :id)
87+
for row in eachrow(d_spiders)
88+
isnothing(row.x) && (row.x = 0)
89+
isnothing(row.y) && (row.y = 0)
90+
end
8691

8792
spec = @vgplot($schema="https://vega.github.io/schema/vega/v5.json",
8893
height=y_range,

0 commit comments

Comments
 (0)