0

例如,下面显示了两个图。我怎样才能在一个情节中绘制它们?

import pandas as pd
import pandas_bokeh
pd.set_option('plotting.backend', 'pandas_bokeh')
pandas_bokeh.output_notebook()

pd.Series(np.random.randint(0, 7, size=10)).plot(kind='line')
pd.Series(np.random.randint(0, 3, size=10)).plot(kind='bar')

在此处输入图像描述

4

1 回答 1

0

我建议使用bokeh,因为据我所知pandas-bokeh没有加入情节的选项,我不想展示解决方法。

这是一个与您的输出接近的普通散景示例:

import pandas as pd
from bokeh.plotting import figure, show, output_notebook
output_notebook()

s1 = pd.DataFrame(np.random.randint(0, 7, size=10), columns=['line'])
s2 = pd.DataFrame(np.random.randint(0, 3, size=10), columns=['bar'])

p = figure(width=300, height=300)
p.line(x='index', y='line', color='blue', alpha=0.5, source=s1, legend_label='line')
p.vbar(x='index', top='bar', color='red', alpha=0.5, source=s2, legend_label='bar')
p.legend.click_policy='hide'
show(p)

例子

于 2021-12-22T10:49:05.700 回答