Skip to content

Commit 1e88899

Browse files
committed
merge master, make rate labels optional, drop GLMakie
1 parent 3277354 commit 1e88899

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

docs/src/model_creation/model_visualisation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ If you wish to copy the output to your [clipboard](https://en.wikipedia.org/wiki
3636
For a model to be nicely displayed you have to use an IDE that actually supports this (such as a [notebook](https://jupyter.org/)). Other environments (such as [the Julia REPL](https://docs.julialang.org/en/v1/stdlib/REPL/)) will simply return the full LaTeX code which would generate the desired expression.
3737

3838
## [Displaying model networks](@id visualisation_graphs)
39-
Catalyst uses `GraphMakie` to display representations of chemical reaction networks, including the complex graph and the species-reaction graph (which is similar to the [Petri net](https://en.wikipedia.org/wiki/Petri_net) representation). To get started, import Catalyst and GraphMakie to load the `CatalystGraphMakieExtension` extension, and then load a Makie backend (`GLMakie` is recommended).
39+
Catalyst uses `GraphMakie` to display representations of chemical reaction networks, including the complex graph and the species-reaction graph (which is similar to the [Petri net](https://en.wikipedia.org/wiki/Petri_net) representation). To get started, import Catalyst, GraphMakie, and NetworkLayout to load the `CatalystGraphMakieExtension` extension, and then load a Makie backend (`CairoMakie` is a good lightweight choice).
4040

4141
```@example visualisation_graphs
42-
using Catalyst, GraphMakie
43-
using GLMakie
42+
using Catalyst, GraphMakie, NetworkLayout
43+
using CairoMakie
4444
nothing # hide
4545
```
4646

docs/src/model_creation/network_analysis.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tutorial we showed how the above network could be visualized as a
3232
species-reaction graph. There, species are represented by the nodes of the graph
3333
and edges show the reactions in which a given species is a substrate or product.
3434
```@example s1
35-
using Catalyst, GraphMakie, GLMakie
35+
using Catalyst, GraphMakie, NetworkLayout, CairoMakie
3636
g = plot_network(repressilator)
3737
```
3838

@@ -190,7 +190,7 @@ Reaction complexes give an alternative way to visualize a reaction network
190190
graph. Catalyst's [`plot_complexes`](@ref) command will calculate the complexes of
191191
a network and then show how they are related. For example,
192192
```@example s1
193-
using Catalyst, GraphMakie, GLMakie
193+
using Catalyst, GraphMakie, NetworkLayout, CairoMakie
194194
plot_complexes(rn)
195195
```
196196

ext/CatalystGraphMakieExtension/rn_graph_plot.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function Catalyst.plot_network(rn::ReactionSystem; kwargs...)
191191
end
192192

193193
layout = if !haskey(kwargs, :layout)
194-
is_connected(srg) ? Stress() : Spring()
194+
Stress()
195195
end
196196
graphplot(srg;
197197
layout,
@@ -209,7 +209,7 @@ function Catalyst.plot_network(rn::ReactionSystem; kwargs...)
209209
end
210210

211211
"""
212-
plot_complexes(rn::ReactionSystem; kwargs...)
212+
plot_complexes(rn::ReactionSystem; show_rate_labels = false, kwargs...)
213213
214214
Creates a GraphMakie plot of the [`ReactionComplex`](@ref)s in `rn`. Reactions
215215
correspond to arrows and reaction complexes to blue circles.
@@ -219,10 +219,12 @@ end
219219
parameter or a `Number`. i.e. `k, A --> B`.
220220
- Red arrows from complexes to complexes indicate reactions whose rate
221221
depends on species. i.e. `k*C, A --> B` for `C` a species.
222+
- The `show_rate_labels` keyword, if set to `true`, will annotate each edge
223+
with the rate constant for the reaction.
222224
223225
For a list of accepted keyword arguments to the graph plot, please see the [GraphMakie documentation](https://graph.makie.org/stable/#The-graphplot-Recipe).
224226
"""
225-
function Catalyst.plot_complexes(rn::ReactionSystem; kwargs...)
227+
function Catalyst.plot_complexes(rn::ReactionSystem; show_rate_labels = false, kwargs...)
226228
rxs = reactions(rn)
227229
specs = species(rn)
228230
edgecolors = [:black for i in 1:length(rxs)]
@@ -238,13 +240,13 @@ function Catalyst.plot_complexes(rn::ReactionSystem; kwargs...)
238240
# 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).
239241
cg, rxorder = ComplexGraphWrap(rn)
240242

241-
layout = if !haskey(kwargs, :layout)
242-
is_connected(cg) ? Stress() : Spring()
243+
layout = if !haskey(kwargs, :layout)
244+
Stress()
243245
end
244246
graphplot(cg;
245247
layout,
246248
edge_color = edgecolors[rxorder],
247-
elabels = edgelabels[rxorder],
249+
elabels = show_edge_labels ? edgelabels[rxorder] : [],
248250
ilabels = complexlabels(rn),
249251
node_color = :skyblue3,
250252
elabels_rotation = 0,

0 commit comments

Comments
 (0)