我有两个不同的数据帧,具有相同的列,我想创建一个交互式绘图,并将两个子图放在同一个图中。在
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上看到了一些例子,但是我不能用袖扣做到这一点。在
你能帮帮我吗?在
Tags:
虽然有关于这件事的文档,但我在获取正确的信息以制作子图方面遇到了很多麻烦。到目前为止,我得到的解决方案是:
第一部分很重要,我在导入文档中描述的模块时遇到了很多问题,因此“工具”是一个子模块,它显然完成了以下工作:
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')
;