Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2fd2aa

Browse filesBrowse files
efiringQuLogic
authored andcommitted
Merge pull request #5625 from tacaswell/faq_datetime64
DOC: add FAQ about np.datetime64
1 parent fed6bdd commit e2fd2aa
Copy full SHA for e2fd2aa

File tree

Expand file treeCollapse file tree

1 file changed

+29
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-0
lines changed

‎doc/faq/howto_faq.rst

Copy file name to clipboardExpand all lines: doc/faq/howto_faq.rst
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,35 @@ How-To
1414
Plotting: 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

1948
Find all objects in a figure of a certain type

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.