diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b64a225..2a239b8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,11 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true + - name: Install LaTeX + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends texlive texlive-latex-extra cm-super lmodern dvipng + - name: Install dependencies env: BEZIER_IGNORE_VERSION_CHECK: "1" diff --git a/docs/assets/plots/ck_test.png b/docs/assets/plots/ck_test.png index 59d2777..3afe50e 100644 Binary files a/docs/assets/plots/ck_test.png and b/docs/assets/plots/ck_test.png differ diff --git a/docs/assets/plots/contacts.png b/docs/assets/plots/contacts.png index 2c2365e..e4c37ba 100644 Binary files a/docs/assets/plots/contacts.png and b/docs/assets/plots/contacts.png differ diff --git a/docs/assets/plots/dendrogram.png b/docs/assets/plots/dendrogram.png index 324f4a0..0278816 100644 Binary files a/docs/assets/plots/dendrogram.png and b/docs/assets/plots/dendrogram.png differ diff --git a/docs/assets/plots/macrotraj.png b/docs/assets/plots/macrotraj.png index 44eaf65..82fcef4 100644 Binary files a/docs/assets/plots/macrotraj.png and b/docs/assets/plots/macrotraj.png differ diff --git a/docs/assets/plots/sankey.png b/docs/assets/plots/sankey.png index 1982731..37662aa 100644 Binary files a/docs/assets/plots/sankey.png and b/docs/assets/plots/sankey.png differ diff --git a/docs/assets/plots/state_network.png b/docs/assets/plots/state_network.png index 93da967..de47fba 100644 Binary files a/docs/assets/plots/state_network.png and b/docs/assets/plots/state_network.png differ diff --git a/docs/assets/plots/timescales_kl.png b/docs/assets/plots/timescales_kl.png index 2744e3f..ec632d1 100644 Binary files a/docs/assets/plots/timescales_kl.png and b/docs/assets/plots/timescales_kl.png differ diff --git a/docs/assets/plots/timescales_t.png b/docs/assets/plots/timescales_t.png index 8d90d84..66af451 100644 Binary files a/docs/assets/plots/timescales_t.png and b/docs/assets/plots/timescales_t.png differ diff --git a/docs/assets/plots/transition_matrix.png b/docs/assets/plots/transition_matrix.png index f1cc334..b5395ab 100644 Binary files a/docs/assets/plots/transition_matrix.png and b/docs/assets/plots/transition_matrix.png differ diff --git a/docs/assets/plots/transition_time.png b/docs/assets/plots/transition_time.png index c687d0e..9946deb 100644 Binary files a/docs/assets/plots/transition_time.png and b/docs/assets/plots/transition_time.png differ diff --git a/src/MPP/graph/kinetic_network.py b/src/MPP/graph/kinetic_network.py index db666c4..e3f299b 100755 --- a/src/MPP/graph/kinetic_network.py +++ b/src/MPP/graph/kinetic_network.py @@ -13,6 +13,7 @@ from .._style import FONT_FAMILY pplt.use_style(figsize=1.8, figratio=1) +plt.rcParams["text.usetex"] = True plt.rcParams["font.family"] = [FONT_FAMILY] USE_FA2 = True diff --git a/src/MPP/plot.py b/src/MPP/plot.py index cf1aa84..9adc54a 100755 --- a/src/MPP/plot.py +++ b/src/MPP/plot.py @@ -32,8 +32,9 @@ def _apply_style(**kwargs): - """Call pplt.use_style and enforce the package font family.""" + """Call pplt.use_style and enforce LaTeX rendering with the package font family.""" pplt.use_style(**kwargs) + plt.rcParams["text.usetex"] = True plt.rcParams["font.family"] = [FONT_FAMILY] @@ -255,9 +256,7 @@ def implied_timescales( if first_ref: ref_trajectory = trajectories.pop(0) x, y = utils.get_grid_format(len(trajectories)) - _apply_style( - figsize=(2.7 * scale, 2.7 * scale), latex=False, colors="pastel_autumn" - ) + _apply_style(figsize=(2.7 * scale, 2.7 * scale), colors="pastel_autumn") fig, axs = plt.subplots(y, x, sharex=True, sharey=True) plt.grid(False) if not isinstance(axs, np.ndarray): @@ -381,7 +380,7 @@ def relative_implied_timescales(cl, out): out : str Path to save the output figure. """ - _apply_style(figsize=(8, 2.5), latex=False, colors="pastel_autumn") + _apply_style(figsize=(8, 2.5), colors="pastel_autumn") ref = cl.reference its = cl.timescales / ref.timescales @@ -838,7 +837,6 @@ def contact_rep(contacts, cluster_file, state_trajectory, output, grid, scale=1) figsize=1.2 * scale, colors="pastel_autumn", true_black=True, - latex=False, ) # load files @@ -912,7 +910,7 @@ def contact_rep(contacts, cluster_file, state_trajectory, output, grid, scale=1) pplt.text( 0.5, 0.95, - rf"S{state + 1} {pop_state:.1%}", + rf"S{state + 1} {100 * pop_state:.1f}\%", ha="center", va="top", ax=ax, @@ -1066,7 +1064,6 @@ def rmsd(rmsds, pops, helices=None, filename=None): figsize=(w, h), colors="pastel_autumn", true_black=True, - latex=False, ) fig, axs = plt.subplots( n_plots, @@ -1259,7 +1256,6 @@ def delta_rmsd(rmsds, pops, helices=None, filename=None): figsize=(w, h), colors="pastel_autumn", true_black=True, - latex=False, ) fig, axs = plt.subplots( n_plots, @@ -1443,6 +1439,9 @@ def state_trajectory(trajectory, filename, row_length=0.2, frame_length=0.2): Duration of each frame in ns. Used to scale the x-axis label in μs. (default 0.2) """ + plt.rcParams["text.usetex"] = True + plt.rcParams["font.family"] = [FONT_FAMILY] + if row_length > 1: x_max = int(row_length) elif row_length > 0: @@ -1570,7 +1569,6 @@ def chapman_kolmogorov(mpt, out, frame_length=0.2): figsize=4.8, colors="pastel_autumn", true_black=True, - latex=False, ) nrows, ncols = utils.get_grid_format(mpt.n_macrostates[mpt.run_index]) diff --git a/tests/data/HP35/baseline/js/macrostate_assignment.npy b/tests/data/HP35/baseline/js/macrostate_assignment.npy index 841e437..e73a6d5 100644 Binary files a/tests/data/HP35/baseline/js/macrostate_assignment.npy and b/tests/data/HP35/baseline/js/macrostate_assignment.npy differ diff --git a/tests/data/HP35/baseline/kl/Z.npy b/tests/data/HP35/baseline/kl/Z.npy index 18b2dd6..88e2e7e 100644 Binary files a/tests/data/HP35/baseline/kl/Z.npy and b/tests/data/HP35/baseline/kl/Z.npy differ diff --git a/tests/data/HP35/baseline/kl/macrostate_assignment.npy b/tests/data/HP35/baseline/kl/macrostate_assignment.npy index 7589a6d..7dbe026 100644 Binary files a/tests/data/HP35/baseline/kl/macrostate_assignment.npy and b/tests/data/HP35/baseline/kl/macrostate_assignment.npy differ diff --git a/tests/data/HP35/baseline/t/Z.npy b/tests/data/HP35/baseline/t/Z.npy index 534020e..626ce6c 100644 Binary files a/tests/data/HP35/baseline/t/Z.npy and b/tests/data/HP35/baseline/t/Z.npy differ diff --git a/tests/data/HP35/baseline/t/macrostate_assignment.npy b/tests/data/HP35/baseline/t/macrostate_assignment.npy index cf52882..b7f9d7b 100644 Binary files a/tests/data/HP35/baseline/t/macrostate_assignment.npy and b/tests/data/HP35/baseline/t/macrostate_assignment.npy differ diff --git a/tests/data/HP35/baseline/t_js/macrostate_assignment.npy b/tests/data/HP35/baseline/t_js/macrostate_assignment.npy index 6268f15..1d75672 100644 Binary files a/tests/data/HP35/baseline/t_js/macrostate_assignment.npy and b/tests/data/HP35/baseline/t_js/macrostate_assignment.npy differ diff --git a/tests/data/HP35/expected_output/gpcca/Z.npy b/tests/data/HP35/expected_output/gpcca/Z.npy index ebef561..e1e88e7 100644 Binary files a/tests/data/HP35/expected_output/gpcca/Z.npy and b/tests/data/HP35/expected_output/gpcca/Z.npy differ diff --git a/tests/data/PDZ3/baseline/kl/Z.npy b/tests/data/PDZ3/baseline/kl/Z.npy index fd92b9e..d710141 100644 Binary files a/tests/data/PDZ3/baseline/kl/Z.npy and b/tests/data/PDZ3/baseline/kl/Z.npy differ diff --git a/tests/data/aSyn/baseline/kl_js/macrostate_assignment.npy b/tests/data/aSyn/baseline/kl_js/macrostate_assignment.npy index f9c06ec..d4c7230 100644 Binary files a/tests/data/aSyn/baseline/kl_js/macrostate_assignment.npy and b/tests/data/aSyn/baseline/kl_js/macrostate_assignment.npy differ diff --git a/tests/data/aSyn/baseline/t/Z.npy b/tests/data/aSyn/baseline/t/Z.npy index a084cbc..bbdecfe 100644 Binary files a/tests/data/aSyn/baseline/t/Z.npy and b/tests/data/aSyn/baseline/t/Z.npy differ diff --git a/tests/data/aSyn/baseline/t/macrostate_assignment.npy b/tests/data/aSyn/baseline/t/macrostate_assignment.npy index 41b9af5..ad67a40 100644 Binary files a/tests/data/aSyn/baseline/t/macrostate_assignment.npy and b/tests/data/aSyn/baseline/t/macrostate_assignment.npy differ diff --git a/tests/test_plots.py b/tests/test_plots.py index 238f525..27f45a8 100644 --- a/tests/test_plots.py +++ b/tests/test_plots.py @@ -259,12 +259,15 @@ def _assert_font_family(self, dataset, kind, d, g, stochastic=False): / f"Z{'_stochastic' if stochastic else ''}.npy" ) - observed_fonts = [] + observed = [] original_savefig = matplotlib.figure.Figure.savefig def capturing_savefig(fig_self, fname, *args, **kwargs): - observed_fonts.append(list(plt.rcParams.get("font.family", []))) + observed.append({ + "usetex": plt.rcParams.get("text.usetex"), + "font.family": list(plt.rcParams.get("font.family", [])), + }) return original_savefig(fig_self, fname, *args, **kwargs) with tempfile.TemporaryDirectory() as tmpdir: @@ -276,14 +279,18 @@ def capturing_savefig(fig_self, fname, *args, **kwargs): _run_main_with_args(args) self.assertTrue( - len(observed_fonts) > 0, + len(observed) > 0, f"savefig was never called for plot kind '{kind}'", ) - for fonts in observed_fonts: + for snapshot in observed: + self.assertTrue( + snapshot["usetex"], + f"text.usetex is not True for plot kind '{kind}': {snapshot}", + ) self.assertIn( FONT_FAMILY, - fonts, - f"Font family '{FONT_FAMILY}' not found in {fonts} for plot kind '{kind}'", + snapshot["font.family"], + f"Font family '{FONT_FAMILY}' not set for plot kind '{kind}': {snapshot}", ) def test_font_dendrogram(self):