File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,35 @@ How-To
1414Plotting: howto
1515===============
1616
17+ .. _howto-datetime64 :
18+
19+ Plot `numpy.datetime64 ` values
20+ ------------------------------
21+
22+ For matplotlib to plot dates (or any scalar with units) a converter
23+ to float needs to be registered with the `matplolib.units ` module. The
24+ current best converters for `datetime64 ` values are in `pandas `. Simply
25+ importing `pandas ` ::
26+
27+ import pandas as pd
28+
29+ should be sufficient as `pandas ` will try to install the converters
30+ on import. If that does not work, or you need to reset `munits.registry `
31+ you can explicitly install the `pandas ` converters by ::
32+
33+ from pandas.tseries import converter as pdtc
34+ pdtc.register()
35+
36+ If you only want to use the `pandas ` converter for `datetime64 ` values ::
37+
38+ from pandas.tseries import converter as pdtc
39+ import matplotlib.units as munits
40+ import numpy as np
41+
42+ munits.registry[np.datetime64] = pdtc.DatetimeConverter()
43+
44+
45+
1746.. _howto-findobj :
1847
1948Find all objects in a figure of a certain type
You can’t perform that action at this time.
0 commit comments