Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Format Seaborn x axis to MM/DD/YYYY Format

I am wondering how to format my X axis : Currently my axis looks like as follow :

enter image description here

The dream would be to get :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

Strugling with this, I tried to convert my Date array to other formats but still does not work.

Currently My array is :

DateList = np.array(list(MaVar['Dates'].tail(6)))

Print(DateList)
-------------
[Timestamp('2021-09-30 00:00:00') Timestamp('2021-10-31 00:00:00')
 Timestamp('2021-11-30 00:00:00') Timestamp('2021-12-31 00:00:00')
 Timestamp('2022-01-31 00:00:00') Timestamp('2022-02-28 00:00:00')]

The code where I set x axis is below :

sns.heatmap(MatrixData, xticklabels=DateList)

>Solution :

Extract the dates from the Timestamps with dt.date:

DateList = np.array(list(MaVar['Dates'].dt.date.tail(6)))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading