How to plot a spectrum with dB as y-axis with PythonPlot

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?

What I have so far:

using ControlSystemsBase, PythonPlot

function todb(mag)
    20 * log10(mag)
end

P = tf(0.01934, [1, 0.01934])

w = exp10.(LinRange(-6, 1, 200));
mag, w1 = bode(P, w)
mag = mag[:]

db = true
if db
    plot(w, todb.(mag))
    ax = gca()
    ax.set_xscale("log")
    ylabel("Magnitude [dB]", fontsize = 14)
else
    loglog(w, mag)
end
xlabel("Frequency [rad/s]", fontsize = 14)

grid(true, which="both", ls="-.")
nothing

Figure_1

That’s good enough even without custom formatter…