Skip to content

Commit 4d9a72f

Browse files
committed
add example script to plot branching simulation
1 parent 56378ee commit 4d9a72f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

examples/plot.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import cr_bayesian_optim as crb
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
5+
if __name__ == "__main__":
6+
# Define Parameters for Simulation
7+
options = crb.Options(show_progressbar=True)
8+
options.domain.domain_size = 2000
9+
options.time.t_max = 2000
10+
11+
# Load Results or Run new Simulation if needed
12+
cells, out_path = crb.sim_branching.load_or_compute_full(options)
13+
14+
# Specify bounds for visualizing the intracellular
15+
# and extracellular concentrations
16+
intra_bounds = (0.5, 1)
17+
extra_bounds = (0, 10.0)
18+
19+
# Plots the last iteration of the simulation
20+
last_iter = sorted(cells.keys())[-1]
21+
crb.plotting.plot_iteration(
22+
last_iter,
23+
intra_bounds,
24+
extra_bounds,
25+
out_path,
26+
)
27+
28+
# Simple Plot to visualize the Growth Curve
29+
x = np.array(sorted(cells.keys())) * options.time.dt / 60
30+
y = [len(cells[i]) for i in cells.keys()]
31+
32+
fig, ax = plt.subplots()
33+
ax.set_title("Number of Cells")
34+
ax.plot(x, y, color=crb.plotting.COLOR1)
35+
ax.set_xlabel("Time [min]")
36+
plt.show()

0 commit comments

Comments
 (0)