Skip to content

go.Scatter incorrect traceback message for color type error #1212

@100518832

Description

@100518832

Trying to plot a scatter plot of points, total 40 colour groups, get the following trace-back that doesn't make sense.

summaries = terror_data[['Summary', 'Group']].loc[(terror_data['Group'].isin(terror_data['Group'].value_counts().index.values.tolist()[1:40])) & (terror_data['Group'] != 'unknown')]

summaries['Summary'] = summaries['Summary'].apply(lambda x: re.sub(r'.*:', '', x).lower().strip())
regex = re.compile('[^a-zA-Z]')
summaries['Summary'] = summaries['Summary'].apply(lambda x: regex.sub('', x))
summaries.reset_index(inplace=True)

tagged_docs = []
for doc, tag in zip(summaries['Summary'], summaries['Group']):
    tagged_docs.append(TaggedDocument(words=word_tokenize(doc), tags=[tag]))

model = Doc2Vec(vector_size=20, alpha=0.025, min_count=1, dm=1)
model.build_vocab(tagged_docs)

for epoch in range(25):
    model.train(tagged_docs, total_examples=model.corpus_count, epochs=model.iter)
    model.alpha -= 0.0002
    model.min_alpha = model.alpha 
    
vectors = []
for doc in summaries['Summary']:
    vectors.append(model.infer_vector(doc.split()))

points = umap.UMAP(n_components=2, random_state=32).fit_transform(vectors)

traces = []

markercl = cl.scales['11']['qual']['Paired']
cl.to_html(markercl)

markercl = cl.interp(markercl, len(summaries['Group'].value_counts().index.values.tolist()))
cl.to_html(markercl)


count = 0
for group, color in zip(numpy.unique((summaries['Group'].values).tolist()), array):
    x = points[[summaries['Group'].loc[summaries['Group']==group].index.values.tolist()],0].tolist()[0]
    y = points[[summaries['Group'].loc[summaries['Group']==group].index.values.tolist()],1].tolist()[0]
    
    trace = go.Scatter(
        x = x,
        y = y,
        name = group,
        mode = 'markers',
        marker = dict(
            size = 2,
            color = str(markercl[count])
        ),
    )
    
    traces.append(trace)
    count += 1
    
fig = go.Figure(data=traces)
py.iplot(fig)

ValueError:
Invalid value of type 'builtins.str' received for the 'color' property of scatter.marker
Received value: 'hsl(-4.999999999999993, 37.36842105263159%, 73.26315789473684%)'

The 'color' property is a color and may be specified as:
  - A hex string (e.g. '#ff0000')
  - An rgb/rgba string (e.g. 'rgb(255,0,0)')
  - An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
  - An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
  - A named CSS color:
        aliceblue, antiquewhite, aqua, aquamarine, azure,
        beige, bisque, black, blanchedalmond, blue,
        blueviolet, brown, burlywood, cadetblue,
        chartreuse, chocolate, coral, cornflowerblue,
        cornsilk, crimson, cyan, darkblue, darkcyan,
        darkgoldenrod, darkgray, darkgrey, darkgreen,
        darkkhaki, darkmagenta, darkolivegreen, darkorange,
        darkorchid, darkred, darksalmon, darkseagreen,
        darkslateblue, darkslategray, darkslategrey,
        darkturquoise, darkviolet, deeppink, deepskyblue,
        dimgray, dimgrey, dodgerblue, firebrick,
        floralwhite, forestgreen, fuchsia, gainsboro,
        ghostwhite, gold, goldenrod, gray, grey, green,
        greenyellow, honeydew, hotpink, indianred, indigo,
        ivory, khaki, lavender, lavenderblush, lawngreen,
        lemonchiffon, lightblue, lightcoral, lightcyan,
        lightgoldenrodyellow, lightgray, lightgrey,
        lightgreen, lightpink, lightsalmon, lightseagreen,
        lightskyblue, lightslategray, lightslategrey,
        lightsteelblue, lightyellow, lime, limegreen,
        linen, magenta, maroon, mediumaquamarine,
        mediumblue, mediumorchid, mediumpurple,
        mediumseagreen, mediumslateblue, mediumspringgreen,
        mediumturquoise, mediumvioletred, midnightblue,
        mintcream, mistyrose, moccasin, navajowhite, navy,
        oldlace, olive, olivedrab, orange, orangered,
        orchid, palegoldenrod, palegreen, paleturquoise,
        palevioletred, papayawhip, peachpuff, peru, pink,
        plum, powderblue, purple, red, rosybrown,
        royalblue, saddlebrown, salmon, sandybrown,
        seagreen, seashell, sienna, silver, skyblue,
        slateblue, slategray, slategrey, snow, springgreen,
        steelblue, tan, teal, thistle, tomato, turquoise,
        violet, wheat, white, whitesmoke, yellow,
        yellowgreen
  - A number that will be interpreted as a color
    according to scatter.marker.colorscale
  - A list or array of any of the above

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions