Preserve original timezone vs. automatic UTC conversion in Matplotlib date handling
0 reputation · 13 Nov 2022, 22:18 UTC
Goal
Determine whether Matplotlib should retain the original timezone information of datetime inputs on the Axis object to simplify local‑time tick labeling, rather than requiring users to write custom Formatters that convert UTC‑based numbers back to a desired zone.
Constraints and uncertainty
The current implementation converts all timezone‑aware datetimes to UTC via date2num, stripping tzinfo and storing only the UTC‑based floating‑point day value. Changing this behavior must preserve backward compatibility, avoid breaking existing scripts that rely on the UTC representation, and correctly handle daylight‑saving transitions when mixing naïve and aware timestamps.
Key considerations are the added complexity of storing tzinfo per axis, the potential need for a new axis.timezone attribute, and whether a built‑in local‑time formatter would be preferable to exposing raw tzinfo.
- Should Matplotlib add an
axis.timezoneattribute to preserve the original zone? - Would a built‑in formatter that applies the stored offset reduce user boilerplate?
- How would this change affect plots that mix naïve and timezone‑aware series?