0

我有两个不同的数据框,具有相同的列,我想创建一个交互式图并将两个子图放在同一个图中。

avg1 = (flowData_AR.pivot_table(index=flowData_AR['TimeStamp'].dt.month.rename('month'),
                            values='Value', aggfunc=np.mean))

avg2 = (flowData_OIJ.pivot_table(index=flowData_OIJ['TimeStamp'].dt.month.rename('month'),
                            values='Value', aggfunc=np.mean))

avg1.iplot(kind='line', subplots=True,xTitle='Month', yTitle='Average', title='aaa')
avg2.iplot(kind='line',subplots=True, xTitle='Month', yTitle='Average', title='bbb')

我一直在尝试,并在以下位置查看示例:https ://plot.ly/ipython-notebooks/cufflinks/#dataframes但我无法使用 Cufflinks 做到这一点。

请你帮助我好吗?

4

1 回答 1

1

尽管在情节中有关于此事的文档,但我在获取正确的信息以制作子情节方面遇到了很多麻烦。这是我到目前为止的解决方案:

第一部分很重要,我在导入文档中描述的模块时遇到了很多问题,因此“工具”是显然可以完成工作的子模块:

from plotly import tools 
import plotly.plotly as py
import plotly.graph_objs as go

#This generates the traces for the subplots:

trace1 = pol_part_corr_1.corr().iplot(kind='heatmap',colorscale="Reds")
trace2 = pol_part_corr_2.corr().iplot(kind='heatmap',colorscale="Reds")

#Create the plot matrix:
fig = tools.make_subplots(rows=2, cols=1)

#Add traces, in this case is a hitmap so the method used is 'add_traces', for other plots it might be 'append_trace'.

fig.add_traces(trace1)
fig.add_traces(trace2)

fig['layout'].update(height=600, width=600, title='PARTICLES CORRELATION')
py.plot(fig, filename='subplots-shared-xaxes')

于 2019-07-27T19:18:50.970 回答