Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

ColorScale based on timestamp

Hello!

I was wondering if it was possible to use timestamps as the value for color scale. I want use the color scale as a visual timestamps, black is at right in the morning with xx,xx,xxxx 0:30:00 and the white is at night xx,xx,xxxx 23:42:00. I was trying this:

    size='16',
    cmin=0,
    cmax=25,

    color = df.Time,#set color equal to a variable

colorscale=‘Viridis’,

** colorscale=[[??/??/2017 00:00:00,‘rgb(0,0,0 )’],[xx,xx,2017 23:59:59,‘rgb(255,255,255)’]],**
showscale=True

The text in bold is what I hoped to do, however I keep getting the generic color scale which is white to red. Any thoughts?

Cheers,
Lindsey

@Lindsey A colorscale is defined as a list of lists, and the first element in the inner list should be a number in the interval [0,1], i.e. in your case
colorscale=[[0, 'rgb(0,0,0)'], [1.0, 'rgb(255,255,255)']].
I suppose that you want to use such a colorscale for coloring a table (a heatmap) according to the time, hh:mm:ss.
To be able to do such a coloring you must find a function that maps each time between 00:00:00 and 23:59:59 to an interval [a,b] of the z-values for the heatmap. Moreover such a function should preserve the order: iftimestamp1<timestamp2, then the corresponding values, v1, v2, must be in the relation v1<=v2.
Such a function could be one that associates to each time the hour in the interval [0,23].