How to custom the hover text of a box plot

My code is as follows, but itโ€™s not working
plotly.py version is 6.4.0

import plotly.graph_objects as go

data = [24, 14, 18, 27, 17, 32, 31, 27, 21, 27, 24, 21, 24, 26, 31, 34]
fig = go.Figure()
data_n = len(data)
max_ = np.max(data)
min_ = np.min(data)
q1 = np.quantile(data, 0.25)
q3 = np.quantile(data, 0.75)
iq_range = q3 - q1
median = np.median(data)
fig.add_trace(
    go.Box(
        x=data,
        fillcolor='#7da7d9',
        line={'color': 'black', 'width': 1},
        # hoverinfo = 'none',
        hoveron='boxes',
        hovertemplate=(
            f"Q1 = {q1:.6g}<br>"
            f"median = {median:.6g}<br>"
            f"Q3 = {q3:.6g}<br>"
            f"IQRange = {iq_range:.6g}<br>"
            f"Whisker = ({min_:.6g},{max_:.6g})<br>"
            f"N = {data_n}<br>"
        ),
        name=''
    )
)
fig.update_layout(width=600, height=400)
fig.show()

I think you might have a slight misconception of how the hovertemplate works.

You canโ€™t just use f- strings to show variables in the hover. The data you want to show needs (I think) to be self contained within the figure. Like this example: