【发布时间】:2016-04-10 15:08:18
【问题描述】:
我在绘制熊猫系列时遇到了一个问题。 当使用日期时间 x 轴绘制系列时,x 轴在缩放时会相应地重新标记,即它工作正常:
from matplotlib import pyplot as plt
from numpy.random import randn
from pandas import Series,date_range
import numpy as np, pandas as pd
date_index = date_range('1/1/2016', periods=6*24*7, freq='10Min')
ts = Series(randn(len(date_index)), index=date_index)
ts.plot(); plt.show()
但是,当我将系列索引重新定义为字符串时,发生了一件奇怪的事情,缩放不再正常工作(限制似乎没有改变)
sindex=np.vectorize(lambda s: s.strftime('%d.%m %H:%M'))(ts.index.to_pydatetime())
ts = Series(randn(len(date_index)), index=sindex)
ts.plot(); plt.show()
这是一个错误还是我误用/误解了?建议/帮助将非常受欢迎。
我还注意到,使用 kind='bar' 进行绘图相对默认而言非常慢(使用更长的向量),我不确定它的起源是什么......
【问题讨论】:
标签: python pandas plot axis-labels