Black Lives Matter. Please consider donating to Black Girls Code today.

Why am I getting error: 'dash' is not allowed in 'scatter'?


Why am I getting the following errors when I execute the line of code as shown below:

plotly.exceptions.PlotlyDictKeyError: ‘dash’ is not allowed in ‘scatter’
Path To Error: [‘dash’]
Valid attributes for ‘scatter’ at path [] under parents []: …

Line of code:
trace1 = go.Scatter(x=MFTdf[‘MFT’], y=MFTdf[‘MFT Planned Complete’], mode = ‘lines’, name = ‘MFT Planned’, line = dict(color = ‘rgb(255, 127, 14)’), dash = ‘dot’)

In the error paragraph, it mentions that ‘dash’ is not a valid attribute, but how can that be? I extracted this from the Plotly-API reference:
dash (string)
_default: “solid” _
Sets the dash style of lines. Set to a dash type string (“solid”, “dot”, “dash”, “longdash”, “dashdot”, or “longdashdot”) or a dash length list in px (eg “5px,10px,2px,2px”).

and here is an example from the Plotly website:
trace5 = go.Scatter(
x = month,
y = low_2000,
name = ‘Low 2000’,
line = dict(
color = (‘rgb(22, 96, 167)’),
width = 4,
dash = ‘dot’)

Well after careful reading and going back and forth between the example and the reference documentation, it turns out that dash was previously an attribute of scatter. The example shows dash as an attribute, but now in the documentation, dash is now a argument within the attribute line.

Well at least I figured it out on my own and hence, improving my understanding and programming.