Gibberish / malformed negative y-axis values in plotly charts in python

The following code duplicates the problem for me:

#!/usr/bin/env python3
"""Test negative bug."""

from plotly.subplots import make_subplots

fig = make_subplots(rows=1, cols=1)
fig.add_bar(x=[1, 2, 3], y=[-4, 5, -6], row=1, col=1)
fig.update_layout(height=400, width=500, showlegend=True)

with open('web/negative.html', 'w', encoding='utf-8') as index_file:
    index_file.write(fig.to_html(full_html=False))

This results in:

neg

When I change to full_html=True, it works properly:

pos

This seems to be a recent bug because it worked fine before I upgraded Plotly. I’m using this version from conda-forge:

plotly 5.13.1 pyhd8ed1ab_0 conda-forge

1 Like