Skip to content

Adding a layout shape line with custom dash lenght lists is not working #3375

Closed

Description

@dvd7587

Example:
plotly.graph_objects.layout.shape.Line(color='black', width=2, dash='5px,3px,3px,2px')

produces the following:

ValueError: 
    Invalid value of type 'builtins.str' received for the 'dash' property of layout.shape.line
        Received value: '5px,3px,3px,2px'

    The 'dash' property is a string and must be specified as:
      - One of the following strings:
            ['solid', 'dot', 'dash', 'longdash', 'dashdot',
            'longdashdot']
      - A number that will be converted to a string

Moreover, the documentation and the Line docstring state that it should be allowed, but the layout.shape.Line.dash property docstring states otherwise.

Activity

  1. kvanderwijst commented on Feb 28, 2022

    @kvanderwijst

    Had the same issue. After looking around a bit, I found that the problem is that the DashValidator from validators/layout/shape/line inherits from StringValidator instead of DashValidator (same actually for validators/scattersmith/line and validators/layout/newshape/line). Changing this line:

    class DashValidator(_plotly_utils.basevalidators.StringValidator):
    

    to this:

    class DashValidator(_plotly_utils.basevalidators.DashValidator):
    

    in the file C:\Users\[USER]\Anaconda3\Lib\site-packages\plotly\validators\layout\shape\line\_dash.py on Windows (probably similar on Linux/Mac) fixes the issue. Not sure how to make a patch of this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions