8000 dates: add warning for usec precision with high years · matplotlib/matplotlib@74d354d · GitHub
[go: up one dir, main page]

Skip to content

Commit 74d354d

Browse files
committed
dates: add warning for usec precision with high years
The warning threshold of is based on the assumption that the user really wants full microsecond resolution in the plot, and expects the plot frame to come out nicely (no jagged corners). Besides being able to identify accurate tick labels/positions, it requires a small "accuracy margin" for the drawing operations. If we assume a desired accuracy of 50ns in the underlying numerical time data, we need to go back to at least the year 27. It cannot hurt to start warning about the issue slightly earlier, hence the treshold is set to 20.
1 parent bc92319 commit 74d354d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/dates.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,10 @@ def get_locator(self, dmin, dmax):
13071307
locator = RRuleLocator(rrule, self.tz)
13081308
else:
13091309
locator = MicrosecondLocator(interval, tz=self.tz)
1310+
if dmin.year > 20:
1311+
warnings.warn('The MicrosecondLocator needs early years'
1312+
' to work really well. Please see the'
1313+
' documentation for details.')
13101314

13111315
locator.set_axis(self.axis)
13121316

0 commit comments

Comments
 (0)
0