plotly.py: Custom values for `griddash`, e.g. '10px' don't work (plotly.js 2.12.0)

Custom values for griddash, e.g. ‘10px’ don’t work (plotly.js 2.12.0)

Example:

import plotly.express as px
df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col="species")
fig.update_xaxes(tickcolor="black", tickwidth=2, ticklen=10, ticklabelmode="period", griddash='10px')
fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='LightPink')

fig.show()

Gives the following error

ValueError: 
    Invalid value of type 'builtins.str' received for the 'griddash' property of layout.xaxis
        Received value: '10px'

    The 'griddash' 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

@archmoj, should it work like this? That throws an error fig.update_xaxes(showgrid=True, gridwidth=1, gridcolor='LightPink', griddash='10px')

_Originally posted by @LiamConnors in https://github.com/plotly/plotly.py/pull/3693#discussion_r865489690_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (22 by maintainers)

Most upvoted comments

Let’s fix this in the next patch release. I’m almost done QA’ing 5.8.0 already.

Could you simply set it to 10px?

yes that works also