I am using PythonPlot and want to have a logarithmic y axis formatted in dezibel (dB). In Python I could use the following code:
from UliEngineering.Math.Decibel import *
import matplotlib.ticker as mtick
def decibel_formatter(v0=1.0, unit='dB'):
def format_value(value, pos=None):
dB = value_to_dB(value, v0=v0)
return f'{dB:.0f} {unit}'
return format_value
# Usage example:
plt.gca().set_yscale("log") # Optional
plt.gca().yaxis.set_major_formatter(mtick.FuncFormatter(decibel_formatter()))
Source: https://techoverflow.net/2023/03/13/how-to-format-axis-as-db-decibel-using-matplotlib/
How can I do this in Julia? In particular, how can I write a custom formatter in Julia?