2017-08-25 247 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)