Skip to content

Commit

Permalink
Save figure for "plot two strain ts" script
Browse files Browse the repository at this point in the history
To improve compatibility with MyBinder, this commit swaps interactive plotting with TkAgg + plt.show() to saving figure output as PNG with Agg + plt.savefig().
  • Loading branch information
trvrb committed Jul 11, 2022
1 parent 225babf commit f89193e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion models/exercise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Subscript indices refer to the status with respect to strains 1 and 2, respectiv
Compare answers with your neighbors, and be sure to raise any interesting points of disagreement (or agreement or confusion) with the class.

For this next section you'll need to download a Python script. You can download it [here](https://github.com/trvrb/sismid/blob/master/models/exercise/exercise.zip?raw=true). Download this and uncompress it.
For this next section you'll need to run a Python script.

This can either be downloaded [here](https://github.com/trvrb/sismid/blob/master/models/exercise/exercise.zip?raw=true) and run locally or can be run directly from within MyBinder at [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/trvrb/sismid/HEAD). This script outputs the figure `fig_plot_two_strain_ts.png`.

Let's assume we think this model is a pretty good starting point for testing hypotheses.
We'll numerically integrate these equations to see what they predict.
Expand Down
6 changes: 3 additions & 3 deletions models/exercise/plot_two_strain_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import csv
import numpy as np
import matplotlib as mpl
mpl.use('TkAgg')
from matplotlib.font_manager import FontProperties
mpl.use('Agg')
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
from two_strain import *

Expand Down Expand Up @@ -85,5 +85,5 @@
plt.ylabel('Infected 2')
plt.legend(loc=1, prop=FontProperties(size='smaller'))
plt.savefig("time_series_" + str(run_num) + ".png")
plt.show()
plt.savefig("fig_plot_two_strain_ts.png", dpi=200)
plt.close()

0 comments on commit f89193e

Please sign in to comment.