From 308c469f81e396c82d51f4b8b86bfc269d5d4513 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Thu, 30 Mar 2023 11:28:29 +0200 Subject: [PATCH] updated plot labels and legend --- caimira/apps/calculator/report_generator.py | 4 ++-- caimira/apps/calculator/static/js/report.js | 2 +- caimira/apps/templates/base/calculator.report.html.j2 | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/caimira/apps/calculator/report_generator.py b/caimira/apps/calculator/report_generator.py index 4b01c4f7..39919fac 100644 --- a/caimira/apps/calculator/report_generator.py +++ b/caimira/apps/calculator/report_generator.py @@ -132,7 +132,7 @@ def calculate_report_data(form: FormData, model: models.ExposureModel) -> typing ]) prob = np.array(model.infection_probability()) - prob_dist_count, prob_dist_bins = np.histogram(prob, bins=100, density=True) + prob_dist_count, prob_dist_bins = np.histogram(prob/100, bins=100, density=True) prob_probabilistic_exposure = np.array(model.total_probability_rule()).mean() er = np.array(model.concentration_model.infected.emission_rate_when_present()).mean() exposed_occupants = model.exposed.number @@ -234,7 +234,7 @@ def uncertainties_plot(exposure_model: models.ExposureModel): axs[1, 0].set_xticklabels(['$10^{' + str(i) + '}$' for i in range(2, 13, 2)]) axs[1, 0].set_xlim(2, 10) axs[1, 0].set_xlabel('Viral load\n(RNA copies)', fontsize=12) - axs[0, 0].set_ylabel('Probability of infection\nfor a given viral load', fontsize=12) + axs[0, 0].set_ylabel('Conditional Probability\nof Infection', fontsize=12) axs[0, 0].text(9.5, -0.01, '$(i)$') axs[1, 0].text(9.5, axs[1, 0].get_ylim()[1] * 0.8, '$(ii)$') diff --git a/caimira/apps/calculator/static/js/report.js b/caimira/apps/calculator/static/js/report.js index 79be0c88..49286914 100644 --- a/caimira/apps/calculator/static/js/report.js +++ b/caimira/apps/calculator/static/js/report.js @@ -980,7 +980,7 @@ function draw_histogram(svg_id, prob, prob_sd) { // Plot tile vis.append("svg:text") - .attr("x", x(50)) + .attr("x", x(0.5)) .attr("y", 0 + margins.top) .attr("text-anchor", "middle") .style("font-size", "16px") diff --git a/caimira/apps/templates/base/calculator.report.html.j2 b/caimira/apps/templates/base/calculator.report.html.j2 index d5e4902e..cba60719 100644 --- a/caimira/apps/templates/base/calculator.report.html.j2 +++ b/caimira/apps/templates/base/calculator.report.html.j2 @@ -207,11 +207,16 @@
- +
{% if form.conditional_probability_plot %}
+
+

(i)   Predictive probability of infection for a given value of the viral load

+

(ii)  Histogram of the viral load data

+

(iii) Histogram of the conditional probability of infection (result of total predictive probability in the middle)

+
{% endif %}