# Label color bars with date-time strings

**URL:** <https://forum.generic-mapping-tools.org/t/label-color-bars-with-date-time-strings/1802>\
**Category:** Q&A\
**Created:** [June 17, 2021, 5:17am UTC](https://forum.generic-mapping-tools.org/t/label-color-bars-with-date-time-strings/1802 "2021-06-17T05:17:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tianzeliu](https://avatars.discourse-cdn.com/v4/letter/t/f17d59/32.png) [@tianzeliu](https://forum.generic-mapping-tools.org/u/tianzeliu)\
**Post date:** [June 17, 2021, 5:17am UTC](https://forum.generic-mapping-tools.org/t/label-color-bars-with-date-time-strings/1802/1 "2021-06-17T05:17:31Z")

</div>

Hi There,  
I am having trouble labeling my color bar with the date and time represented by the colors. Currently, the labels seem to be seconds since a certain time, but I want them to be date-time strings such as 2012-01-01-00-00-00. I am using GMT 6.1.1. Here is an excerpt of my codes:

> gmt begin test pdf
> 
> # Plot the coast lines
> 
> gmt coast -JH-88.5/8i -R-180/180/-90/90 -A10000 -Bwsne -Bxa0f0g0 -Bya0f0g0 -Dl -Ggray -Swhite -Cwhite
> 
> # Make the colorscale
> 
> gmt makecpt -Cjet -T2012-06-29T08:00:00/2013-10-18T11:00:00
> 
> # Plot the colorbar
> 
> gmt colorbar -DJMR -B  
> gmt end show

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [June 17, 2021, 5:39am UTC](https://forum.generic-mapping-tools.org/t/label-color-bars-with-date-time-strings/1802/2 "2021-06-17T05:39:37Z")

</div>

Did you try -Baf with your colorbar call?

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [June 17, 2021, 6:01am UTC](https://forum.generic-mapping-tools.org/t/label-color-bars-with-date-time-strings/1802/3 "2021-06-17T06:01:27Z")

</div>

Seems you need to specify a unit to turn the CPT into a datestring cpt. I tried 1 hr and then the annotations worked better

gmt makecpt -Cjet -T2012-06-29T08:00:00/2013-10-18T11:00:00/1h \> t.cpt  
gmt colorbar -Ct.cpt -Dx4i/4i+w3i -B -pdf t

---

<div class="post-metadata">

**Author:** ![tianzeliu](https://avatars.discourse-cdn.com/v4/letter/t/f17d59/32.png) [@tianzeliu](https://forum.generic-mapping-tools.org/u/tianzeliu)\
**Post date:** [June 17, 2021, 6:46pm UTC](https://forum.generic-mapping-tools.org/t/label-color-bars-with-date-time-strings/1802/4 "2021-06-17T18:46:19Z")

</div>

That works. Thanks!
