feat(notebooks): Add matplotlib configuration for SVG font rendering in plots to use string only with no embedded fonts

This commit is contained in:
nuluh
2025-08-30 08:11:29 +07:00
parent f2d427f0e8
commit 30ecb6a88a

View File

@@ -419,6 +419,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
"from typing import Union" "from typing import Union"
] ]
}, },
@@ -447,6 +448,7 @@
" plt.ylabel('Sampel Frekuensi (Hz)')\n", " plt.ylabel('Sampel Frekuensi (Hz)')\n",
" plt.xticks(np.linspace(0, len(data)-1, x_num_ticks)) # Set x-ticks at regular intervals\n", " plt.xticks(np.linspace(0, len(data)-1, x_num_ticks)) # Set x-ticks at regular intervals\n",
" plt.yticks(np.linspace(0, len(data.columns)-1, y_num_ticks)) # Set y-ticks at regular intervals\n", " plt.yticks(np.linspace(0, len(data.columns)-1, y_num_ticks)) # Set y-ticks at regular intervals\n",
" mpl.rcParams['svg.fonttype'] = None\n",
" plt.savefig(\"output_single.svg\", format=\"svg\", dpi=100)\n", " plt.savefig(\"output_single.svg\", format=\"svg\", dpi=100)\n",
" plt.show()\n", " plt.show()\n",
"\n", "\n",
@@ -477,6 +479,7 @@
" # Adjust layout\n", " # Adjust layout\n",
" # plt.tight_layout(rect=[0.05, 0.05, 1, 1]) # Leave space for shared labels\n", " # plt.tight_layout(rect=[0.05, 0.05, 1, 1]) # Leave space for shared labels\n",
" plt.subplots_adjust(left=0.1, right=0.75, top=0.9, bottom=0.1, wspace=0.2, hspace=0.2)\n", " plt.subplots_adjust(left=0.1, right=0.75, top=0.9, bottom=0.1, wspace=0.2, hspace=0.2)\n",
" mpl.rcParams['svg.fonttype'] = None\n",
" plt.savefig(\"output_multiple.svg\", format=\"svg\", dpi=80)\n", " plt.savefig(\"output_multiple.svg\", format=\"svg\", dpi=80)\n",
" plt.show()" " plt.show()"
] ]