#!/usr/bin/env python3 """Supplementary figure: missing, observed zero, and observed value.""" from __future__ import annotations import matplotlib.pyplot as plt from matplotlib.patches import Rectangle from style import ( BLUE, COLUMN_WIDTH_IN, INK, LIGHT_GREY, MID_GREY, SMALL_TEXT_PT, HERE, save_figure, ) OUTPUT = HERE / "fig_missing_zero.pdf" def main() -> None: fig, ax = plt.subplots(figsize=(COLUMN_WIDTH_IN, 1.55)) fig.subplots_adjust(left=0.34, right=0.98, bottom=0.08, top=0.96) ax.set_xlim(0, 5) ax.set_ylim(-0.55, 2.65) ax.axis("off") rows = [ (2.05, "missing"), (1.05, "observed zero"), (0.05, "observed value"), ] for y, label in rows: ax.text(-0.08, y, label, ha="right", va="center", clip_on=False) ax.add_patch( Rectangle( (0.20, y - 0.31), 4.55, 0.62, facecolor="none", edgecolor=LIGHT_GREY, lw=0.75, ls=(0, (3, 2)), ) ) sample_x = [0.62, 1.52, 2.42, 3.32, 4.22] ax.plot([0.32, 4.63], [1.05, 1.05], color=MID_GREY, lw=0.55) ax.scatter(sample_x, [1.05] * len(sample_x), s=18, color=BLUE, zorder=3) ax.plot([0.32, 4.63], [0.05, 0.05], color=MID_GREY, lw=0.55) observed = [0.22, 0.39, 0.27, 0.50, 0.34] ax.vlines(sample_x, 0.05, observed, color=BLUE, lw=0.7) ax.scatter(sample_x, observed, s=18, color=BLUE, zorder=3) ax.annotate( "", xy=(4.63, -0.42), xytext=(0.32, -0.42), arrowprops={"arrowstyle": "-|>", "color": MID_GREY, "lw": 0.55}, ) ax.text( 2.48, -0.42, "time", ha="center", va="center", color=MID_GREY, bbox={"facecolor": "white", "edgecolor": "none", "pad": 0.5}, ) # A compact key, not a consequence diagram. ax.plot([0.30, 0.78], [2.52, 2.52], color=LIGHT_GREY, lw=0.75, ls=(0, (3, 2))) ax.text( 0.88, 2.52, "expected", ha="left", va="center", fontsize=SMALL_TEXT_PT, color=MID_GREY, ) ax.scatter([3.55], [2.52], s=18, color=BLUE) ax.text( 3.77, 2.52, "delivered", ha="left", va="center", fontsize=SMALL_TEXT_PT, color=MID_GREY, ) save_figure( fig, OUTPUT, subject="Three categorical delivery states for optional telemetry", ) if __name__ == "__main__": main()