2017-08-25 248 views
0

如何從Plot.ly熱圖子圖graph below中的內部y軸刪除數字和刻度?兩個圖共享相同的y軸範圍,所以沒有理由顯示兩者。Python Plotly熱圖子圖 - 刪除內部Y軸號和刻度

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


import pandas as pd 
import numpy as np 


dfl = [] 

dfl.append(pd.DataFrame(np.random.random((100,100,)))) 
dfl.append(pd.DataFrame(np.random.random((100,100,)))) 


fig = tools.make_subplots(rows=1, cols=len(dfl) ,print_grid=False); 

for index, a in enumerate(dfl): 

    sn = str(index) 

    data = go.Heatmap(
      z=a.values.tolist(), 
      colorscale='Viridis', 
      colorbar=dict(title='units'), 
     ) 

    fig.append_trace(data, 1, index+1) 
    fig['layout']['xaxis'+str(index+1)].update(title='xaxis '+str(index)) 

fig['layout']['yaxis1'].update(title='y-axis') 
fig['layout'].update(height=600, width=800, title='heatmap subplots') 
py.iplot(fig) 

Heatmap subplots

回答

0

只需通過設定 'shared_yaxes =真' 到tools.make_subplots函數調用,那就是:

fig = tools.make_subplots(rows=1, cols=len(dfl) ,print_grid=False, shared_yaxes=True)