Skip to content

Commit 74cfd21

Browse files
authored
Merge pull request #1345 from SciML/dmw/plot_complexes_edgecolors
Set `edge_color` in `plot_complexes` regardless of whether edge labels are shown or not
2 parents 9a5bce6 + eda59f4 commit 74cfd21

File tree

1 file changed

+19
-33
lines changed

1 file changed

+19
-33
lines changed

ext/CatalystGraphMakieExtension/rn_graph_plot.jl

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -238,44 +238,30 @@ function Catalyst.plot_complexes(rn::ReactionSystem; show_rate_labels::Bool = fa
238238

239239
# Get complex graph and reaction order for edgecolors and edgelabels. rxorder gives the order of reactions(rn) that would match the edge order in edges(cg).
240240
cg, rxorder = ComplexGraphWrap(rn)
241+
edgelabels = show_rate_labels ? [repr(rxs[i].rate) for i in rxorder] : nothing
242+
deps = Set()
243+
edgecolors = map(rxorder) do i
244+
empty!(deps)
245+
get_variables!(deps, rxs[i].rate, specs)
246+
return isempty(deps) ? :black : :red
247+
end
241248

242249
layout = if !haskey(kwargs, :layout)
243250
Stress()
244251
end
245252

246-
if show_rate_labels
247-
edgelabels = [repr(rxs[i].rate) for i in rxorder]
248-
deps = Set()
249-
edgecolors = map(rxorder) do i
250-
empty!(deps)
251-
get_variables!(deps, rxs[i].rate, specs)
252-
return isempty(deps) ? :black : :red
253-
end
254-
255-
f = graphplot(cg;
256-
layout,
257-
edge_color = edgecolors,
258-
elabels = edgelabels,
259-
ilabels = complexlabels(rn),
260-
node_color = :skyblue3,
261-
elabels_rotation = 0,
262-
arrow_shift = :end,
263-
curve_distance_usage = true,
264-
curve_distance = gen_distances(cg),
265-
kwargs...
266-
)
267-
else
268-
f = graphplot(cg;
269-
layout,
270-
ilabels = complexlabels(rn),
271-
node_color = :skyblue3,
272-
arrow_shift = :end,
273-
curve_distance_usage = true,
274-
curve_distance = gen_distances(cg),
275-
kwargs...
276-
)
277-
end
278-
253+
f = graphplot(cg;
254+
layout,
255+
edge_color = edgecolors,
256+
elabels = edgelabels,
257+
elabels_rotation = 0,
258+
ilabels = complexlabels(rn),
259+
node_color = :skyblue3,
260+
arrow_shift = :end,
261+
curve_distance_usage = true,
262+
curve_distance = gen_distances(cg),
263+
kwargs...
264+
)
279265
f.axis.xautolimitmargin = (0.15, 0.15)
280266
f.axis.yautolimitmargin = (0.15, 0.15)
281267
hidedecorations!(f.axis)

0 commit comments

Comments
 (0)