{"spec_id":"datamatrix-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\ndatamatrix-basic: Basic Data Matrix 2D Barcode\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 86/100 | Updated: 2026-05-20\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\n\nsns.set_theme(\n    style=\"ticks\",\n    rc={\n        \"figure.facecolor\": PAGE_BG,\n        \"axes.facecolor\": ELEVATED_BG,\n        \"axes.edgecolor\": INK_SOFT,\n        \"text.color\": INK,\n        \"xtick.color\": INK_SOFT,\n        \"ytick.color\": INK_SOFT,\n    },\n)\n\n# Data — 10x10 Data Matrix (ISO/IEC 16022 ECC 200) encoding \"ANYPLOT\"\nnp.random.seed(42)\nsize = 10\nmatrix = np.zeros((size, size), dtype=int)\n\n# L-shaped finder pattern: solid black left column and bottom row\nmatrix[:, 0] = 1\nmatrix[-1, :] = 1\n\n# Alternating clock pattern: top row and right column\nfor i in range(size):\n    matrix[0, i] = i % 2\nfor i in range(size):\n    matrix[i, -1] = i % 2\n\n# Interior 8x8 data region (simulated ECC 200 payload for \"ANYPLOT\")\ndata_pattern = np.array(\n    [\n        [1, 0, 1, 1, 0, 1, 0, 1],\n        [0, 1, 1, 0, 1, 0, 1, 0],\n        [1, 0, 0, 1, 1, 1, 0, 1],\n        [0, 1, 1, 0, 0, 1, 1, 0],\n        [1, 1, 0, 1, 0, 0, 1, 0],\n        [0, 0, 1, 0, 1, 1, 0, 1],\n        [1, 0, 1, 1, 0, 0, 1, 0],\n        [0, 1, 0, 0, 1, 1, 0, 1],\n    ]\n)\nmatrix[1 : size - 1, 1 : size - 1] = data_pattern\n\n# Plot — square canvas (2400x2400 px: figsize=(6,6) dpi=400)\nfig, ax = plt.subplots(figsize=(6, 6), dpi=400, facecolor=PAGE_BG)\n\nsns.heatmap(\n    matrix,\n    cmap=[\"white\", \"black\"],\n    cbar=False,\n    square=True,\n    linewidths=0,\n    linecolor=\"white\",\n    xticklabels=False,\n    yticklabels=False,\n    ax=ax,\n)\n\n# Quiet zone: 1-module white border around the barcode (ISO/IEC 16022 requirement)\nax.set_xlim(-1, size + 1)\nax.set_ylim(size + 1, -1)\n\n# Style\nax.set_title(\"datamatrix-basic · python · seaborn · anyplot.ai\", fontsize=12, fontweight=\"medium\", color=INK, pad=12)\nax.set_xlabel(\"Encoded: 'ANYPLOT' · ISO/IEC 16022 ECC 200 · 10×10\", fontsize=9, color=INK_SOFT)\nfor spine in ax.spines.values():\n    spine.set_visible(False)\n\nax.set_facecolor(ELEVATED_BG)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}