我使用下面的代码使用 plotly 包创建了一行两列的子图。但是两个 x 轴重叠(参见随附的屏幕截图)。第一个情节的轴涵盖了这两个情节。如何解决这个问题?我没有从情节网站上看到一个很好的例子。另外如何删除图例?
import plotly
import plotly.graph_objs as go
def plot(plot_dic, width=1000, **kwargs):
kwargs['output_type'] = 'div'
plot_str = plotly.offline.plot(plot_dic, **kwargs)
print('%%angular <div style=" width: %spx"> %s </div>' % ( width, plot_str))
# Create a trace
trace0 = go.Scatter(
x = np.arange(100)+1,
y = np.round(df[df['']=='value'].iloc[:,1:]*100, 2).values.reshape(100),
mode = 'lines+markers',
)
trace1 = go.Scatter(
x = np.arange(100)+1,
y = np.cumsum(np.round(df[df['']=='value'].iloc[:,1:]*100, 2).values).reshape(100),
mode = 'lines+markers',
)
fig = plotly.tools.make_subplots(rows=1, cols=2, subplot_titles=('Variance', 'Cumulative Variance')
# ,shared_xaxes=True, shared_yaxes=True
)
fig['layout'].update(height=500, width=800, title="Plot title"
,xaxis=dict(range = [1, 400],
dtick = 40,
showticklabels=True,
tickfont=dict(family='Arial, sans-serif', size=14, color='black'),
exponentformat='e',
showexponent='all')
,xaxis1=dict(range = [1, 400],
dtick = 40,
showticklabels=True,
tickfont=dict(family='Arial, sans-serif', size=14, color='black'),
exponentformat='e',
showexponent='all')
)
fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 2)
plot(fig, width=600, show_link=False)