我有一个自定义日期格式的列:YYYYWeekNo
例如201801201802…201851201852
当我有从201752跳到201801的数据时,问题就出现了,这创建了一个图,将数据视为100比例的连续数据,因此图形是扭曲的
有没有办法用非连续的x
标签来解析这个图?你知道吗
x = []
year = 2017
for i in range(104):
j = i+1
if j <= 52:
x.append(year * 100 + j)
else:
k = j - 52
x.append(((year+1) * 100 ) + k)
np.random.seed(1)
values = np.random.randint(low=0, high=5000, size=104)
df = pd.DataFrame.from_dict({'year_week': x, 'values': values})
df.set_index('year_week').plot(figsize=(15, 5))
可以使用matplotlib example来“打断”轴。这将是定制版本:
输出:
更重要的是,似乎有一个专门解决这个问题的软件包:
Brokenaxes
相关问题 更多 >
编程相关推荐