Pygmt pygmt.makecpt with dates / times

Dear all,
I am struggling to make a colorscale with date in the format yyyy-mm-ddThh:mm:ss
I tried

pygmt.config(FORMAT_DATE_IN='yyyy-mm-dd')
pygmt.config(FORMAT_DATE_OUT='yyyy-mm-dd')

pygmt.makecpt(
    cmap='rainbow',
    series=['2021-01-01T','2021-03-01T'],
    output='date.cpt',
    verbose=True
    )

Things are not clear for me… I’ll appreciate if someone could help. That was quite easy with GMT6 !!
Thanks
cecile

Hi Cecile, Could you share the gmt command that you used for creating the colormap with dates/times? This would help for testing how to get the output equivalent. Thanks!

Hello
Actually, I realised that I always built the colorcale by hand. However, it could be great to build it using makecpt.
However, I was able to plot it with the correct dates:
gmt psscale -Cdate_coloscale.cpt -Dx18/4c+w-4c/0.3c+jTC -Bxaf+l"time" -R -J > $psfile_gen_time
with date_coloscale.cpt :
2009-11-26T 127 0 255 2010-03-01T 0 0 255
2010-03-01T 0 0 255 2010-06-01T 0 255 255
2010-06-01T 0 255 255 2010-09-01T 0 255 0
2010-09-01T 0 255 0 2010-12-01T 255 255 0
2010-12-01T 255 255 0 2011-03-06T 255 0 0
Many thanks
Cécile

Me again,
After using a colorscale made “by hand”, I am struggling again to plot the dots with a color consistent with the time (coltypes=“T”?).

fig.plot(
    x=lon,
    y=lat,
    style='c', 
    size=M,
    color=date_st,
    coltypes="T",
    pen='black',
    cmap=file_cpt_name
    )

Using GMT6, I used to write:
gmt psxy file_to_plot.xyt -R -V -W0.5 -Jm -Sc0.4 -C$file_cpt_name -fi2T > $psfile

Many thanks
Cécile

To be equivalent to the gmt command, you would use coltypes="i2T":

fig.plot(
x=lon,
y=lat,
style=‘c’,
size=M,
color=date_st,
coltypes=“i2T”,
pen="black",
cmap=file_cpt_name
)

The hand-made colormap is a discrete colormap. To create a discrete colormap using makecpt, the increment needs to be specified in the series argument (example below uses a 1 month increment):

import pygmt

pygmt.config(FORMAT_DATE_IN='yyyy-mm-dd')
pygmt.config(FORMAT_DATE_OUT='yyyy-mm-dd')

pygmt.makecpt(
    cmap='turbo',
    series=['2021-01-01T','2021-12-01T','1o'],
    output='date.cpt',
    verbose=True
    )

Dear Meghan,
I tried and it does not work.
I remain confused with the coltypes=“i2T”. With GMT it was related to the third column. In this case, how to know that it is related to ‘color’…
Sorry, but I am lost
Cécile