相关疑难解决方法(0)

使用matplotlib绘制numpy datetime64

我有两个numpy数组1D,一个是datetime64格式的测量时间,例如:

array([2011-11-15 01:08:11, 2011-11-16 02:08:04, ..., 2012-07-07 11:08:00], dtype=datetime64[us])
Run Code Online (Sandbox Code Playgroud)

和其他具有整数数据的相同长度和维度的数组.
我想在matplotlib时间与数据中制作一个图.如果我直接输入数据,这就是我得到的:

plot(timeSeries, data)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

有没有办法让时间更自然?例如,在这种情况下,月/年可以.

编辑:
我已经尝试过Gustav Larsson的建议,但是我收到了一个错误:

Out[128]:
[<matplotlib.lines.Line2D at 0x419aad0>]
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/zmq/pylab/backend_inline.pyc in show(close)
    100     try:
    101         for figure_manager in Gcf.get_all_fig_managers():
--> 102             send_figure(figure_manager.canvas.figure)
    103     finally:
    104         show._to_draw = []

/usr/lib/python2.7/dist-packages/IPython/zmq/pylab/backend_inline.pyc in send_figure(fig)
    209     """
    210     fmt = InlineBackend.instance().figure_format
--> 211     data = print_figure(fig, fmt)
    212     # print_figure will return None if there's nothing to draw:
    213     if data is None:

/usr/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in …
Run Code Online (Sandbox Code Playgroud)

python datetime numpy matplotlib

22
推荐指数
2
解决办法
2万
查看次数

标签 统计

datetime ×1

matplotlib ×1

numpy ×1

python ×1