33Matplotlib provides sophisticated date plotting capabilities, standing
44on the shoulders of python :mod:`datetime`, the add-on modules
55:mod:`pytz` and :mod:`dateutils`. :class:`datetime` objects are
6- converted to floating point numbers which represent the number of days
7- since 0001-01-01 UTC. The helper functions :func:`date2num`,
6+ converted to floating point numbers which represent time in days
7+ since 0001-01-01 UTC, plus 1. For example, 0001-01-01, 06:00 is
8+ 1.25, not 0.25. The helper functions :func:`date2num`,
89:func:`num2date` and :func:`drange` are used to facilitate easy
910conversion to and from :mod:`datetime` and numeric ranges.
1011
@@ -225,7 +226,7 @@ def date2num(d):
225226 *d* is either a :class:`datetime` instance or a sequence of datetimes.
226227
227228 Return value is a floating point number (or sequence of floats)
228- which gives number of days (fraction part represents hours,
229+ which gives one plus the number of days (fraction part represents hours,
229230 minutes, seconds) since 0001-01-01 00:00:00 UTC.
230231 """
231232 if not cbook .iterable (d ): return _to_ordinalf (d )
@@ -235,17 +236,18 @@ def date2num(d):
235236def julian2num (j ):
236237 'Convert a Julian date (or sequence) to a matplotlib date (or sequence).'
237238 if cbook .iterable (j ): j = np .asarray (j )
238- return j + 1721425 .5
239+ return j - 1721424 .5
239240
240241def num2julian (n ):
241242 'Convert a matplotlib date (or sequence) to a Julian date (or sequence).'
242243 if cbook .iterable (n ): n = np .asarray (n )
243- return n - 1721425 .5
244+ return n + 1721424 .5
244245
245246def num2date (x , tz = None ):
246247 """
247- *x* is a float value which gives number of days (fraction part
248- represents hours, minutes, seconds) since 0001-01-01 00:00:00 UTC.
248+ *x* is a float value which gives one plus the number of days
249+ (fraction part represents hours, minutes, seconds) since
250+ 0001-01-01 00:00:00 UTC.
249251
250252 Return value is a :class:`datetime` instance in timezone *tz* (default to
251253 rcparams TZ value).
0 commit comments