熊猫xaxis自动格式问题

时间:2012-07-23 19:26:33

标签: python matplotlib pandas

from pandas import *
import datetime
DataFrame([1,1], index =  [ datetime.datetime(2012,1,1), datetime.datetime(2012,9,1) ] ).plot()

给出了xaxis不可读的图。我认为原因是在tools\plotting.py condition(决定自动启动)是假的。

condition = (not self._use_dynamic_x
             and df.index.is_all_dates
             and not self.subplots
             or (self.subplots and self.sharex))

第一行不应该是self._use_dynamic_x()吗?

2 个答案:

答案 0 :(得分:2)

我认为这是大熊猫的错误​​,它应该是self._use_dynamic_x(),请将问题发布到熊猫,解决这个问题:

import pylab as pl
from pandas import *
import datetime
df = DataFrame([1,1], index =  [ datetime.datetime(2012,1,1), datetime.datetime(2012,9,1) ] )
df.plot()
pl.xticks(rotation=90)

答案 1 :(得分:1)

你正在使用什么版本的熊猫?

我刚试了一遍,轴看起来很好:

http://imgur.com/FpoR7

我正在使用pandas 0.8.1和matplotlib 1.1.0