Violin plot loses hover text formatting

Expected result: Violin plot hover text has a background color and text color matching/determined by the color of the violin plot.

Actual result: Hover text has a transparent background and white text (hardly visible against white background)

Steps to reproduce

  1. Create new violin plot with the following settings:
trace = {
    "type": "violin",
    "x": ["x", "x", "x", "x", "x"],
    "y": [1, 2, 3.0000001, 4, 5],
    "meanline": {"visible": True},
    "hoverinfo": "y",
    "hoveron": "violins+points+kde"
}
layout = {"plot_bgcolor": "black"}
figure = go.Figure(data=[trace], layout=layout)
  1. Observe the following:


    The hover labels are incorrectly formatted. If points: 'all' is enabled, they also have incorrect formatting.

  2. Change one of the following to restore correct behavior:

  • y: [1, 2, 3.0000001, 4, 5] to y: [1, 2, 3, 4, 5]or format data as strings
  • meanline: {"visible": True} to meanline: {"visible": False}
  • hoveron: "violins+points+kde" to any other option for hoveron, including just "kde"


Example above is with mean line hidden.

Notes: This occurs using the Python API and in the online editor, so I think this is an underlying issue with the plotly.js and its treatment of data with high precision.

Workaround: Convert data to strings instead of floats/ints. (actually this may not be the solution, see below)

Has anyone else run into this problem?

EDIT:
While working with my workaround, I discovered that if the zoom level is not set such that you can see the entire box and whisker plot, then the hover labels are messed up. But when set to a large enough range to span the box, the labels are ok again. Actually, go to the plotly example page for the violin plot and zoom in on the plots and the label formatting disappears.

I’ve opened a Github issue about this.

Tracked in https://github.com/plotly/plotly.js/issues/3875