Skip to content

Commit fc01791

Browse files
committed
adjust plotting defaults
1 parent 4d0e7c2 commit fc01791

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

docs/src/model_creation/model_visualisation.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,36 @@ In this section we demonstrate some of the ways that plot objects can be manipul
8888
f, ax, p = plot_complexes(brusselator, show_rate_labels = true)
8989
```
9090

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`.
91+
It seems like a bit of the top node is cut off. Let's show the tick marks and grid and increase the top and bottom margins by increasing `yautolimitmargin`.
9292
```@example visualisation_graphs
93-
hidedecorations!(ax)
93+
showdecorations!(ax)
9494
ax.yautolimitmargin = (0.1, 0.1) # defaults to (0.05, 0.05)
9595
ax.aspect = DataAspect()
96+
display(F)
9697
```
9798

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.
99+
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. Let's also give the plot a title.
99100
```@example visualisation_graphs
100101
f, ax, p = plot_complexes(brusselator, show_rate_labels = true, node_color = :yellow, ilabels_fontsize = 10)
101-
hidedecorations!(ax)
102-
ax.yautolimitmargin = (0.1, 0.1) # defaults to (0.05, 0.05)
103102
ax.aspect = DataAspect()
104103
ax.title = "Brusselator"
104+
display(f)
105105
```
106106

107107
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/).
108108

109109
Once a graph is already created we can also change the keyword arguments by modifying the fields of the `Plot` object `p`.
110110
```@example visualisation_graphs
111111
p.node_color = :orange
112+
display(f)
112113
```
113114

114115
Custom node positions can also be given, if the automatic layout is unsatisfactory.
115116
```@example visualisation_graphs
116117
fixedlayout = [(0,0), (1,0), (0,1), (1,1), (2,0)]
117118
p.layout = fixedlayout
118119
autolimits!(ax)
120+
display(f)
119121
```
120122

121123
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:

ext/CatalystGraphMakieExtension/rn_graph_plot.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ function Catalyst.plot_network(rn::ReactionSystem; kwargs...)
209209

210210
f.axis.xautolimitmargin = (0.15, 0.15)
211211
f.axis.yautolimitmargin = (0.15, 0.15)
212+
hidedecorations!(f.axis)
213+
f.axis.aspect = DataAspect()
212214

213215
f
214216
end
@@ -260,8 +262,11 @@ function Catalyst.plot_complexes(rn::ReactionSystem; show_rate_labels = false, k
260262
curve_distance = gen_distances(cg),
261263
kwargs...
262264
)
265+
263266
f.axis.xautolimitmargin = (0.15, 0.15)
264267
f.axis.yautolimitmargin = (0.15, 0.15)
268+
hidedecorations!(f.axis)
269+
f.axis.aspect = DataAspect()
265270

266271
f
267272
end

0 commit comments

Comments
 (0)