{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "d310d005-ed50-4fcb-a54a-87ef0de71553",
   "metadata": {},
   "outputs": [],
   "source": [
    "from matplotlib import pyplot as plt\n",
    "import matplotlib.cm\n",
    "import numpy as np\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "9f43c5e5-031c-40c5-b7b0-61ce0ff679e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# https://iamkate.com/data/12-bit-rainbow/\n",
    "rainbow_12bit = ['#817', '#a35', '#c66', '#e94', '#ed0', '#9d5', '#4d8', '#2cb', '#0bc', '#09c', '#36b', '#639']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5e46f8e1-f3ef-492c-a3cb-27a837ced3b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "tcv_data = np.array([\n",
    "[3\t,0\t,None\t,4.10],\n",
    "[3\t,1\t,None\t,2.37],\n",
    "[3\t,4\t,None\t,1.01],\n",
    "[3\t,4\t,None   ,None],\n",
    "[5\t,0\t,0.89\t,2.60],\n",
    "[5\t,1\t,0.59\t,1.34],\n",
    "[5\t,3\t,0.64\t,1.09],\n",
    "[5\t,7\t,0.48\t,0.65],\n",
    "[10\t,0\t,0.73\t,1.74],\n",
    "[10\t,1\t,0.48\t,0.64],\n",
    "[10\t,3\t,0.46\t,0.87],\n",
    "[10\t,7\t,0.31\t,0.58],\n",
    "[25\t,0\t,0.66\t,2.18],\n",
    "[25\t,1\t,0.60\t,1.45],\n",
    "[25\t,3\t,0.61\t,1.17],\n",
    "[25\t,13\t,0.60\t,1.60],\n",
    "])\n",
    "tcv_1mm = tcv_data[:, (0,1,2)]\n",
    "tcv_1mm = tcv_1mm[tcv_1mm[:,2] != None]\n",
    "tcv_4mm = tcv_data[:, (0,1,3)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "eca7fb6a-0ca5-48f6-8f22-493242e11ce5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 52188 characters]",
      "text/plain": [
       "<Figure size 400x350 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots(figsize=(4, 3.5))\n",
    "n_colors = {}\n",
    "handles = []\n",
    "for r, marker, tcv in [(1, 's', tcv_1mm), (4, 'o', tcv_4mm)]:\n",
    "    for n in sorted(set(tcv[:,0])):\n",
    "        sel = tcv[tcv[:,0] == n]\n",
    "        if n not in n_colors:\n",
    "            n_colors[n] = matplotlib.cm.tab10(len(n_colors))\n",
    "        h, = ax.plot(sel[:,1], sel[:,2], label=f'$n={n}, r={r}$', color=n_colors[n], marker=marker, fillstyle='none')\n",
    "        handles.append(h)\n",
    "ax.set_ylabel(r'$V_{ripple,rms} [\\%]$')\n",
    "ax.set_xlabel(r'$k$')\n",
    "ax.set_xticks([0, 1, 3, 7, 13])\n",
    "# hackety hack! https://stackoverflow.com/questions/44575560/centering-matplotlib-legend-entries-within-incomplete-unfilled-rows\n",
    "handles.insert(3, ax.plot([],[],color=(0,0,0,0), label=\" \")[0])\n",
    "ax.legend(handles=handles, loc='upper right', ncol=2, labelspacing=0.3, columnspacing=0.5)\n",
    "ax.grid()\n",
    "\n",
    "# https://matplotlib.org/stable/gallery/text_labels_and_annotations/annotation_demo.html\n",
    "ax.annotate(\n",
    "    'Conventional Single-layer Planar Inductor',\n",
    "    xy=(0, 1), xycoords=('data', 'axes fraction'),\n",
    "    xytext=(30, 40), textcoords='offset points',\n",
    "    arrowprops=dict(arrowstyle=\"->\", connectionstyle=\"angle,angleA=0,angleB=90\"))\n",
    "ax.annotate(\n",
    "    'Conventional Two-layer Planar Inductor',\n",
    "    xy=(1, 1), xycoords=('data', 'axes fraction'),\n",
    "    xytext=(30, 25), textcoords='offset points',\n",
    "    arrowprops=dict(arrowstyle=\"->\", connectionstyle=\"angle,angleA=0,angleB=90\"))\n",
    "ax.annotate(\n",
    "    r'$-$ Our contribution $\\longrightarrow$',\n",
    "    xy=(2, 1.05), xycoords=('data', 'axes fraction'),)\n",
    "ax.axvspan(-1000, 1, color='black', alpha=0.1)\n",
    "ax.set_xlim([-0.3, 13.3])\n",
    "fig.subplots_adjust(top=0.7)\n",
    "\n",
    "fig.savefig('paper/figures/k_ripple_plot.pdf')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
