plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.06k stars 2.54k forks source link

Updating to Plotly.js 2.33.0 breaks existing font weight example #4628

Closed LiamConnors closed 2 months ago

LiamConnors commented 3 months ago

The following example works with Plotly.py 5.22.0 which uses Plotly.js 2.32.0 Trying to update Plotly.py to use Plotly.js 2.33.0 and running codegen and then trying the following example fails:

import plotly.graph_objects as go
from plotly import data

df = data.medals_wide()

fig = go.Figure(
    data=[
        go.Bar(
            x=df.nation,
            y=df.gold,
            name="Gold",
            marker=dict(color="Gold"),
            text="Gold",
            textfont=dict(style="italic"),
        ),
        go.Bar(
            x=df.nation,
            y=df.silver,
            name="Silver",
            marker=dict(color="MediumTurquoise"),
            text="Silver",
            textfont=dict(weight="bold"),
        ),
        go.Bar(
            x=df.nation,
            y=df.bronze,
            name="Bronze",
            marker=dict(color="LightGreen"),
            text="Bronze",
            textfont=dict(variant="small-caps"),
        ),
    ],
    layout=dict(barcornerradius=15, showlegend=False),
)

fig.show()

Error:

    raise ValueError(
ValueError:
    Invalid value of type 'builtins.str' received for the 'weight' property of bar.textfont
        Received value: 'bold'

    The 'weight' property is a integer and may be specified as:
      - An int (or float that will be cast to an int)
        in the interval [1, 1000]
      - A tuple, list, or one-dimensional numpy array of the above