diff --git a/all_countries.py b/all_countries.py index b1e34c6..8e07c57 100644 --- a/all_countries.py +++ b/all_countries.py @@ -61,10 +61,15 @@ def plot(data, countries, pop): if actual_level > warn_thresh: infection_level_indicator = "r" bounds = ax1.axis() - #if warn_thresh < bounds[3]: - 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]], [low_thresh]*2, color="gold", linestyle=":", label=f"5 new cases / week / 1M inh.: {int(low_thresh):,}".replace(",", ".")) + # 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]], [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.axis(bounds) except: