You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Makie graphs can be made to be interactive, allowing one to drag nodes and edges. To do this, we retrieve the axis from the GraphMakie plot, and then register the interactions. **Note that this can only be done if `GLMakie` is the installed Makie backend. See the [GraphMakie docs](https://graph.makie.org/stable/#Predefined-Interactions) for more information about the types of interactions one can register.** Below is a non-interactive code example:
84
+
## Customizing Plots
85
+
In this section we demonstrate some of the ways that plot objects can be manipulated to give nicer images. Let's start with our brusselator plot once again. Note that the `plot` function returns three objects: the `Figure`, the `Axis`, and the `Plot`, which can each be customized independently. See the general [Makie documentation](https://docs.makie.org/stable/) for more information.
86
+
87
+
```@example visualisation_graphs
88
+
f, ax, p = plot_complexes(brusselator, show_rate_labels = true)
89
+
```
90
+
91
+
It seems like a bit of the top node is cut off. Let's hide the tick marks and grid and increase the top and bottom margins by increasing `yautolimitmargin`.
92
+
```@example visualisation_graphs
93
+
hidedecorations!(ax)
94
+
ax.yautolimitmargin = (0.1, 0.1) # defaults to (0.05, 0.05)
95
+
ax.aspect = DataAspect()
96
+
```
97
+
98
+
There are many keyword arguments that can be passed to `plot_network` or `plot_complexes` to change the look of the graph (which get passed to the `graphplot` Makie recipe). Let's change the color of the nodes and make the inner labels a bit smaller. As before, we hide the tick marks and grid. Let's also give the plot a title.
ax.yautolimitmargin = (0.1, 0.1) # defaults to (0.05, 0.05)
103
+
ax.aspect = DataAspect()
104
+
ax.title = "Brusselator"
105
+
```
106
+
107
+
Most of the kwargs that modify the nodes or edges will also accept a vector with the same length as the number of nodes or edges, respectively. See [here](https://graph.makie.org/stable/#The-graphplot-Recipe) for a full list of keyword arguments to `graph_plot`. Note that `plot_complexes` and `plot_network` default to `layout = Stress()` rather than `layout = Spring()`, since `Stress()` is better at generating plots with fewer edge crossings. More layout options and customizations (such as pinning nodes to certain positions) can be found in the [`NetworkLayout` documentation](https://juliagraphs.org/NetworkLayout.jl/stable/).
108
+
109
+
Once a graph is already created we can also change the keyword arguments by modifying the fields of the `Plot` object `p`.
110
+
```@example visualisation_graphs
111
+
p.node_color = :orange
112
+
```
113
+
114
+
Custom node positions can also be given, if the automatic layout is unsatisfactory.
115
+
```@example visualisation_graphs
116
+
fixedlayout = [(0,0), (1,0), (0,1), (1,1), (2,0)]
117
+
p.layout = fixedlayout
118
+
autolimits!(ax)
119
+
```
120
+
121
+
Makie graph plots can be made to be interactive, allowing one to drag nodes and edges. To do this, we retrieve the axis from the GraphMakie plot, and then register the interactions. **Note that this can only be done if `GLMakie` is the installed Makie backend. See the [GraphMakie docs](https://graph.makie.org/stable/#Predefined-Interactions) for more information about the types of interactions one can register.** Below is a non-interactive code example that shows how to do this:
85
122
86
123
```julia
87
124
using GLMakie
@@ -96,3 +133,8 @@ The equivalent of `show` for Makie plots is the `display` function.
96
133
f =plot_network(brusselator)
97
134
display(f)
98
135
```
136
+
137
+
Once you are happy with the graph plot, you can save it using the `save` function.
Creates a GraphMakie plot of the [`ReactionComplex`](@ref)s in `rn`. Reactions
215
-
correspond to arrows and reaction complexes to blue circles.
219
+
Creates a GraphMakie plot of the [`ReactionComplex`](@ref)s in `rn`. Reactions
220
+
correspond to arrows and reaction complexes to blue circles.
216
221
217
-
Notes:
218
-
- Black arrows from complexes to complexes indicate reactions whose rate is a
219
-
parameter or a `Number`. i.e. `k, A --> B`.
220
-
- Red arrows from complexes to complexes indicate reactions whose rate constants
221
-
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.
222
+
Notes:
223
+
- Black arrows from complexes to complexes indicate reactions whose rate is a
224
+
parameter or a `Number`. i.e. `k, A --> B`.
225
+
- Red arrows from complexes to complexes indicate reactions whose rate constants
226
+
depends on species. i.e. `k*C, A --> B` for `C` a species.
227
+
- The `show_rate_labels` keyword, if set to `true`, will annotate each edge
228
+
with the rate constant for the reaction.
224
229
225
230
For a list of accepted keyword arguments to the graph plot, please see the [GraphMakie documentation](https://graph.makie.org/stable/#The-graphplot-Recipe).
226
231
"""
@@ -243,7 +248,7 @@ function Catalyst.plot_complexes(rn::ReactionSystem; show_rate_labels = false, k
0 commit comments