sme_contrib.plot
[1]:
!pip install -q sme_contrib
import sme
import sme_contrib.plot as smeplot
from matplotlib import pyplot as plt
from IPython.display import HTML
Load and simulate example model
[2]:
model = sme.open_example_model()
fig = plt.figure(figsize=(16, 8))
plt.imshow(model.compartment_image)
plt.title("Compartment geometry image")
plt.show()
results = model.simulate(100, 1)
species = ["B_out", "B_cell"]

Plot resulting species concentration
Use default colormap
[3]:
fig = plt.figure(figsize=(16, 8))
smeplot.concentration_heatmap(results[-1], species)
plt.show()

Use a built-in matplotlib colormap
[4]:
fig = plt.figure(figsize=(16, 8))
smeplot.concentration_heatmap(results[-1], species, cmap="flag")
plt.show()

Create your own colormap
[5]:
# make a black -> green colormap using sme_contrib.plot.colormap:
cmap = smeplot.colormap("#00ff00")
fig = plt.figure(figsize=(16, 8))
smeplot.concentration_heatmap(results[-1], species, cmap=cmap)
plt.show()

Display on existing axes with colorbar
[6]:
fig, (ax_l, ax_r) = plt.subplots(nrows=1, ncols=2, figsize=(16, 6))
ax_l, im_l = smeplot.concentration_heatmap(
results[-1], ["B_cell"], cmap=smeplot.colormap("#00ff00"), ax=ax_l
)
ax_r, im_r = smeplot.concentration_heatmap(
results[-1], ["B_out"], cmap=smeplot.colormap("#ff00ff"), ax=ax_r
)
fig.colorbar(im_l, ax=ax_l)
fig.colorbar(im_r, ax=ax_r)
plt.show()

Plot animation of species concentration
[7]:
anim = smeplot.concentration_heatmap_animation(results, ["B_cell"], figsize=(8, 6))
Display as html5 video
[8]:
HTML(anim.to_html5_video())
[8]:
Display as javascript widget
[9]:
HTML(anim.to_jshtml())
[9]: