How to selecting columns in dataframe for hovertemplate?

Hi @NielsHoogeveen, welcome to the forum! Your function does not work because you need to pass to plotly the data which will appear in the hover. The hovertemplate is just a formatted string. You can add customdata to the go.Scatter trace as described in https://plot.ly/python/hover-text-and-formatting/#adding-other-data-to-the-hover-with-customdata-and-a-hovertemplate, or use px.scatter from plotly.express, in which case the syntax would be

px.scatter(df, x=x, y=y, hover_data=['height', 'thickness_1', 'thickness_2'])

Note that you can modify the hovertemplate generated by plotly.express using fig.update_traces.