give float boundaries instead of ints for small countries

This commit is contained in:
fordprefect
2020-09-01 11:13:58 +02:00
parent 981492eb87
commit fb65e5e6fb

View File

@@ -61,7 +61,12 @@ def plot(data, countries, pop):
if actual_level > warn_thresh: if actual_level > warn_thresh:
infection_level_indicator = "r" infection_level_indicator = "r"
bounds = ax1.axis() bounds = ax1.axis()
#if warn_thresh < bounds[3]: # for small population numbers, give floats instead of ints
if pop[loc]['pop'] < 5e6:
ax1.plot([bounds[0], bounds[1]], [warn_thresh]*2, color="red", linestyle=":", label=f"500 new cases / week / 1M inh.: {warn_thresh:1.2f}".replace(",", "."))
ax1.plot([bounds[0], bounds[1]], [info_thresh]*2, color="peru", linestyle=":", label=f"50 new cases / week / 1M inh.: {info_thresh:1.2f}".replace(",", "."))
ax1.plot([bounds[0], bounds[1]], [low_thresh]*2, color="gold", linestyle=":", label=f"5 new cases / week / 1M inh.: {low_thresh:1.2f}".replace(",", "."))
else: # but not for big populations
ax1.plot([bounds[0], bounds[1]], [warn_thresh]*2, color="red", linestyle=":", label=f"500 new cases / week / 1M inh.: {int(warn_thresh):,}".replace(",", ".")) ax1.plot([bounds[0], bounds[1]], [warn_thresh]*2, color="red", linestyle=":", label=f"500 new cases / week / 1M inh.: {int(warn_thresh):,}".replace(",", "."))
ax1.plot([bounds[0], bounds[1]], [info_thresh]*2, color="peru", linestyle=":", label=f"50 new cases / week / 1M inh.: {int(info_thresh):,}".replace(",", ".")) ax1.plot([bounds[0], bounds[1]], [info_thresh]*2, color="peru", linestyle=":", label=f"50 new cases / week / 1M inh.: {int(info_thresh):,}".replace(",", "."))
ax1.plot([bounds[0], bounds[1]], [low_thresh]*2, color="gold", linestyle=":", label=f"5 new cases / week / 1M inh.: {int(low_thresh):,}".replace(",", ".")) ax1.plot([bounds[0], bounds[1]], [low_thresh]*2, color="gold", linestyle=":", label=f"5 new cases / week / 1M inh.: {int(low_thresh):,}".replace(",", "."))