我有一个看起来像这样的df:
data = {'Cumulative': {0: 4, 1: 18, 2: 24, 3: 24, 4: 4, 5: 20, 6: 32, 7: 42}, 'Id': {0: 1, 1: 1, 2: 1, 3: 1, 4: 2, 5: 2, 6: 2, 7: 2}, 'Order': {0: '1-1', 1: '1-2', 2: '1-3', 3: '1-4', 4: '1-1', 5: '1-2', 6: '1-3', 7: '1-4'}, 'Period': {0: 1, 1: 2, 2: 3, 3: 4, 4: 1, 5: 2, 6: 3, 7: 4}, 'Time': {0: '1-1', 1: '1-2', 2: '1-3', 3: '1-4', 4: '1-1', 5: '1-2', 6: '1-3', 7: '1-4'}, 'Year': {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1}}
df = pd.DataFrame(data)
生成的数据框如下:
我想对 Holoviews 做的是为每个 id 绘制一条线。所以“订单”在 x 轴上,“累积”在 y 轴上,每个“Id”都有自己的线(所有颜色都相同)。这是我到目前为止所拥有的,但它并没有给我正确的结果。
%opts Curve [width=600 height=400 show_grid=True ] (color='indianred', alpha=0.5, line_width=1)
kdims=['Order' ] vdims = ['Cumulative',
] ds = hv.Dataset(df.sort_values(by=['Year','Period']), kdims=kdims, vdims= vdims)
ds.to(hv.Curve, ['Order'] ,'Cumulative' )