Skip to content

[Bug]: Datetime axis plot using incorrect locale #23035

Open
@tcplomp

Description

@tcplomp

Bug summary

Datetime format uses US (MM-DD) format on computer that is EN-NZ (DD/MM)
2022-05-12 08_52_44-Python _ Basic Gantt chart using Matplotlib - GeeksforGeeks and 7 more pages - P

Code for reproduction

# adapted from  [example](https://www.geeksforgeeks.org/python-basic-gantt-chart-using-matplotlib/#)

import matplotlib.pyplot as plt
from datetime import datetime,timedelta
# Setting Y-axis limits
fig, gnt = plt.subplots()
gnt.set_ylim(0, 50)

# Setting X-axis limits
startdate = datetime.now() - timedelta(days =3)
enddate =datetime.now() 
gnt.set_xlim(startdate, enddate)
# Setting labels for x-axis and y-axis
gnt.set_xlabel('DateTime')
gnt.set_yticks([15, 25, 35])
gnt.grid(True)    
gnt.broken_barh([(startdate, timedelta(hours =4))], (30, 9), facecolors =('orange'))
plt.show()

Actual outcome

Uploading 2022-05-12 08_52_44-Python _ Basic Gantt chart using Matplotlib - GeeksforGeeks and 7 more pages - P.png…

Expected outcome

Axis to be using DD-MM format

Additional information

No response

Operating system

Windows 10

Matplotlib Version

3.5.2

Matplotlib Backend

TkAgg

Python version

3.8.6

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions