# ColorScale based on timestamp

**URL:** <https://community.plotly.com/t/colorscale-based-on-timestamp/5174>\
**Category:** 📊 Plotly Python\
**Created:** [July 31, 2017, 6:54pm UTC](https://community.plotly.com/t/colorscale-based-on-timestamp/5174 "2017-07-31T18:54:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lindsey](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@Lindsey](https://community.plotly.com/u/Lindsey)\
**Post date:** [July 31, 2017, 6:54pm UTC](https://community.plotly.com/t/colorscale-based-on-timestamp/5174/1 "2017-07-31T18:54:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [August 2, 2017, 12:38pm UTC](https://community.plotly.com/t/colorscale-based-on-timestamp/5174/2 "2017-08-02T12:38:44Z")

</div>

@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: if`timestamp1<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].
