✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Issue with layout.Legend parameter "itemwidth"


I am working on customizing a legend and am receiving the following error when I try to use fig.update_layout(legend=dict(itemwidth=<VALUE>)

ValueError: Invalid property specified for object of type plotly.graph_objs.layout.Legend: 'itemwidth’

According to the documentation it seems this is a valid property. Am I doing something wrong, or is this deprecated? Can anyone else get this property to work?

1 Like

I tried using itemwidth using plotly with Python as well and got the same error. Is there a solution for this?

I’ve created a new issue on Github about this.

@adamlee, @bgbi

The itemwidth must be at least 30. Any value less than this minimum leads to the error you displayed above:

@empet While that’s true, that’s not the error message that appeared. This is what you would see if that were the case:

Invalid value of type 'builtins.int' received for the 'itemwidth' property of layout.legend
        Received value: 20

But the error I got was the same as @adamlee, “invalid property specified.” I was able to solve it as indicated in the Github issue

1 Like

Please note that this attribute was added in a recent version of the library, so it’s normal to see invalid property specified on older versions. The latest version is 4.14.3.

1 Like