Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Issues with title in go.Layout

Hey everyone,

I got this error for the first time

main 'title' has invalid value inside 'layout'

Path To Error: ['title']

The original layout looks like this:

 layout = go.Layout(
        title='Registrations per month',
        xaxis=dict(
            title = 'Month'),
        yaxis=dict(
            title='Registrations' ,
            zeroline=True,
        )
    )

The same persists with the title argument in xaxis and yaxis dictionaries. No changes have been made to the script for a long time (at least 2-3 months) to account for this new error.

Does anyone know a solution to this?

@sandraBB what version of plotly are you using? Also, did you install plotly using pip or is there a chance that the plotly being loaded by your script is from a clone of the plotly repo?

The reason I ask is that plotly.js recently made some changes to how titles are made in the layout/axes so now they are dicts instead of strings but this change will be backwards compatible and shouldn’t have affected any plotly.py versions downloaded and installed using pip.

Hi @sandraBB,

That is a bit puzzling. Based on the error message itself it looks like you have plotly.py version < 3 installed. But the change in the title behavior that @michaelbabyn mentioned hasn’t been released in plotly.py yet. This will be released in plotly.py 3.5.0 soon, and it will still be compatible with this usage of setting the title to a string.

Could you check the plotly version by running pip list and conda list (if you have conda installed)?

-Jon

Hey thanks for the answers! I found it worked on a different computer where I had plotly installed, so it seems likely it is a version issue.

On the computer where I spotted the issue,
conda list gave plotly version of 1.12.2
pip list gave plotly version of 3.4.2

But as you say, seems unlikely that it would have been released already?

Hi @sandraBB,

Thanks for checking the versions. Yeah, having plotly.py installed using both pip and conda can result in confusing errors like this. To get back on track, uninstall plotly using both pip and conda, and then reinstall with just one of them.

Hope that helps!
-Jon