Skip to content

Since Plotly 3.5.0 i get KeyError: 'titlefont' #1403

Closed
@Endogen

Description

@Endogen

This code worked fine until i updated to plotly 3.5.0

        fig['layout'].update(
            title=coin,
            titlefont=dict(
                size=26
            ),
            yaxis=dict(
                title=base_coin,
                titlefont=dict(
                    size=18
                )
            )
        )

But since 3.5.0 i get

File "/usr/local/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3021, in update
    BaseFigure._perform_update(self, kwargs)
  File "/usr/local/lib/python3.7/site-packages/plotly/basedatatypes.py", line 2249, in _perform_update
    validator = plotly_obj._get_prop_validator(key)
  File "/usr/local/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3706, in _get_prop_validator
    return super(BaseLayoutHierarchyType, self)._get_prop_validator(prop)
  File "/usr/local/lib/python3.7/site-packages/plotly/basedatatypes.py", line 2622, in _get_prop_validator
    return self._validators[prop]
KeyError: 'titlefont'

Error seems to be at this line size=18
Is this a bug or do i have to change the way i set the title font?

Here is a bit more context if needed

        fig = fif.create_candlestick(o, h, l, c, pd.to_datetime(t, unit='s'))

        fig['layout']['yaxis'].update(
            tickformat=tickformat,
            tickprefix="   ",
            ticksuffix=f"  ")

        fig['layout'].update(
            title=coin,
            titlefont=dict(
                size=26
            ),
            yaxis=dict(
                title=base_coin,
                titlefont=dict(
                    size=18
                )
            )
        )

        fig['layout'].update(
            shapes=[{
                "type": "line",
                "xref": "paper",
                "yref": "y",
                "x0": 0,
                "x1": 1,
                "y0": c[len(c) - 1],
                "y1": c[len(c) - 1],
                "line": {
                    "color": "rgb(50, 171, 96)",
                    "width": 1,
                    "dash": "dot"
                }
            }])

        fig['layout'].update(
            paper_bgcolor='rgb(233,233,233)',
            plot_bgcolor='rgb(233,233,233)',
            autosize=False,
            width=800,
            height=600,
            margin=go.layout.Margin(
                l=margin_l,
                r=50,
                b=85,
                t=100,
                pad=4
            ))

EDIT: Actually, i'm not sure if this is only an issue in 3.5.0 since i realized that i previously used 3.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions