大熊猫不尊重matplotlib轴?

时间:2018-04-25 14:05:56

标签: python python-3.x pandas matplotlib

以下是一个示例代码:

g = new Dygraph(div, data, {
      series: {
        YourSeries: {
          axis: 'y2'
        }
      }
    });

使用A行,它绘制: enter image description here

使用B行,它绘制: enter image description here

为什么大熊猫import pandas as pd from datetime import datetime, timezone import matplotlib.dates as mdates import matplotlib.pyplot as plt import datetime as dt x = [] d = dt.datetime(2013, 7, 4) for i in range(30): d = d + dt.timedelta(days=1) x.append(d) y = range(len(x)) df = pd.DataFrame({'x': x, 'y': y}) plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%d-%m-%Y')) plt.gca().xaxis.set_major_locator(mdates.DayLocator(interval=5)) # Line A # plt.bar(x, y, align='center') # center the bars on their x-values # Line B # df.plot(x='x', y='y', kind='bar', ax=plt.gca()) plt.title('DateLocator with interval=5') plt.gcf().autofmt_xdate() plt.show() 不尊重轴配置?

这是我的Dataframe.plot

conda env export

0 个答案:

没有答案