簡體   English   中英

Plotly中的子圖-袖扣:如何將兩個子圖放在同一圖中

[英]Subplots in Plotly - Cufflinks: How to put two subplots in the same plot

我有兩個不同的數據框,具有相同的列,並且我想創建一個交互式圖並將兩個子圖放置在同一圖中。

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做到這一點。

請你幫助我好嗎?

盡管有很多有關此問題的文檔,但是在正確獲取信息以進行子圖繪制方面我遇到了很多麻煩。 這是到目前為止我得到的解決方案:

第一部分很重要,導入文檔中描述的模塊時遇到了很多問題,因此“工具”是顯然可以完成工作的子模塊:

 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') 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM