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

Color scale in plotly

Hey together,

a short question:

I have different data points and want to plot them in different graphs. Each data point has an incremented id, which I want to use to define the color for that data point (that it will be unique between graphs).

So, after reading a little bit with the color scales Color Scales:

I choose the following approach:

    scale = cl.scales['12']['qual']['Paired'] 
    colors = cl.to_hsl(cl.interp(scale, (count_objects)))

now I want to define the marker in the loop:
marker=dict( color=colors[i], size=20, line=dict( color='red', width=2 ) ),

where i the incremented id is. The count_objects is 50

I get the error:

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

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%)')

what is wrong with the received format?

Hi!
hsl format shouldn’t have negative values as angle argument.
See: https://github.com/jackparmer/colorlover/issues/21

Thx. But then I don’t understand why cl.interp() gives me an negative value. Is there an easy way to fix that?