feat(notebooks): update magnitude units to use 'm/s²' instead of LaTeX to prevent inkscape misrendered from SVG

This commit is contained in:
nuluh
2025-08-30 11:39:32 +07:00
parent 30ecb6a88a
commit cdcd056102

View File

@@ -443,12 +443,13 @@
" plt.figure(dpi=300) # Set figure size and DPI\n",
" plt.pcolormesh(data.transpose(), cmap='jet', vmax=0.03, vmin=0.0, rasterized=True)\n",
" # plt.title('STFT Preview')\n",
" plt.colorbar(label='Magnitude ($m/s^2$)')\n",
" plt.colorbar(label='Magnitude (m/s²)')\n",
" plt.xlabel('Segmen Waktu')\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.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.rcParams['svg.fonttype'] = 'none'\n",
" plt.rcParams['text.usetex'] = False # use mathtext, not external LaTeX\n",
" plt.savefig(\"output_single.svg\", format=\"svg\", dpi=100)\n",
" plt.show()\n",
"\n",
@@ -462,14 +463,14 @@
" # Loop through each subplot and plot the data\n",
" for i in range(len(data)):\n",
" pcm = axes[i].pcolormesh(data[i].transpose(), cmap='jet', vmax=0.03, vmin=0.0, rasterized=True)\n",
" axes[i].set_title(f'd_{i+1}', fontsize=12)\n",
" axes[i].set_title(f'd{i+1}', fontsize=12)\n",
" axes[i].set_xticks(np.linspace(0, len(data[i])-1, 6)) # Set x-ticks at regular intervals\n",
" axes[i].set_yticks(np.linspace(0, len(data[i].columns)-1, 9)) # Set y-ticks at regular intervals\n",
"\n",
" # Add a single color bar for all subplots\n",
" # Use the first `pcolormesh` object (or any valid one) for the color bar\n",
" cbar = fig.colorbar(pcm, ax=axes, orientation='vertical')\n",
" cbar.set_label('Magnitude ($m/s^2$)', fontsize=12)\n",
" cbar.set_label('Magnitude (m/s²)', fontsize=12)\n",
"\n",
" # Set shared labels\n",
" fig.text(0.5, 0.04, 'Segmen Waktu', ha='center', fontsize=12)\n",
@@ -479,7 +480,9 @@
" # Adjust layout\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",
" mpl.rcParams['svg.fonttype'] = None\n",
" plt.rcParams['svg.fonttype'] = 'none'\n",
" plt.rcParams['text.usetex'] = False # use mathtext, not external LaTeX\n",
" mpl.rcParams['text.usetex'] = False # use mathtext, not external LaTeX\n",
" plt.savefig(\"output_multiple.svg\", format=\"svg\", dpi=80)\n",
" plt.show()"
]