"""Generate the exact parameter figures; matplotlib is optional for the codec.""" from pathlib import Path import numpy as np import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap ROOT=Path(__file__).resolve().parents[1] OUT=ROOT/"figures" OUT.mkdir(exist_ok=True) plt.rcParams.update({"font.family":"DejaVu Sans","font.size":10, "axes.spines.top":False,"axes.spines.right":False, "axes.labelcolor":"#183242","text.color":"#183242", "axes.edgecolor":"#83939a","savefig.bbox":"tight"}) teal,blue,orange="#167f83","#233e70","#b95f25" d=np.arange(2,33) fig,ax=plt.subplots(figsize=(7.4,3.8)) ax.step(d,np.ceil(d/2),where="mid",color=teal,lw=2.4,label="Exact optimum: convolution with a linear relabeling") ax.plot(d,d+1,color=blue,lw=1.8,ls="--",label="Standard constant scalar rays") ax.scatter([16],[8],color=orange,s=48,zorder=4) ax.annotate("GF(256), 65,536 data sites\n24 updates per changed byte",(16,8),xytext=(18,3.0), arrowprops={"arrowstyle":"->","color":orange},fontsize=9) ax.set(xlabel="Dimension d of each data/parity layer",ylabel="Minimum bits per scalar symbol", xlim=(1.5,32.5),ylim=(0,35)) ax.set_xticks([2,4,8,12,16,20,24,28,32]) ax.grid(axis="y",alpha=.2) ax.legend(loc="upper left",frameon=False,fontsize=8.5) fig.tight_layout() for ext in ("pdf","png"):fig.savefig(OUT/f"alphabet_law.{ext}",dpi=170) plt.close(fig) fig,ax=plt.subplots(figsize=(7.4,3.6)) ax.plot(d,d+1,color=blue,lw=2,label="Absolute support lower bound: d + 1") ax.step(d,np.ceil(3*d/2),where="mid",color=teal,lw=2,label="Explicit construction at the optimal alphabet") ax.scatter(np.arange(2,7),np.arange(2,7)+1,s=40,color=orange,zorder=4, label="Exact examples attaining both bounds (d = 2 through 6)") ax.set(xlabel="Dimension d of each layer",ylabel="Parity sites changed by one source update", xlim=(1.5,32.5),ylim=(0,52)) ax.grid(axis="y",alpha=.2) ax.legend(frameon=False,loc="upper left",fontsize=8.3) fig.tight_layout() for ext in ("pdf","png"):fig.savefig(OUT/f"update_support.{ext}",dpi=170) plt.close(fig) fig,ax=plt.subplots(figsize=(7.4,2.4)) sizes=np.arange(1,11) general=np.array([int(x>=3) for x in sizes]) commuting=np.array([int(x==3 or x>=5) for x in sizes]) matrix=np.vstack([commuting,general]) ax.imshow(matrix,cmap=ListedColormap(["#f0d9cc","#d5eeeb"]),vmin=0,vmax=1,aspect="auto") for i in range(2): for j in range(10):ax.text(j,i,"YES" if matrix[i,j] else "NO",ha="center",va="center",fontsize=9) ax.set_xticks(range(10),sizes) ax.set_yticks([0,1],["Normalized commuting maps","Arbitrary binary matrix maps"]) ax.set_xlabel("Source and parity packet length, in bits") ax.set_title("GF(4) geometry, three standard rays, equal packet widths",fontsize=11,pad=12) for spine in ax.spines.values():spine.set_visible(False) ax.set_xticks(np.arange(-.5,10,1),minor=True) ax.set_yticks(np.arange(-.5,2,1),minor=True) ax.grid(which="minor",color="white",lw=3) ax.tick_params(which="minor",bottom=False,left=False) fig.tight_layout() for ext in ("pdf","png"):fig.savefig(OUT/f"noncommuting_gap.{ext}",dpi=170) plt.close(fig)