除了使用烧瓶,如何创建一个带有两个y轴的绘图?在
下面的代码适当地生成了绘图,但我无法计算如何添加布局对象。在
如果使用Plotly是完全不可能的,那么使用Dash是否有一个简单的解决方案?我似乎找不到与链接的绘图示例等价的破折号示例。在
xScale = np.linspace(0, 1, len(acoustic_data))
xScale2 = np.linspace(0, 1, len(time_to_failure))
# Create traces
acoustic_data = go.Scatter(
x=xScale,
y=acoustic_data,
name='acoustic data'
)
time_to_failure = go.Scatter(
x=xScale2,
y=time_to_failure,
name='time to failure',
# yaxis='y2'
)
# How do I integrate the layout?
layout = go.Layout(
title='Earthquick',
yaxis=dict(
title='acoustic data'
),
yaxis2=dict(
title='time to failure',
overlaying='y',
side='right'
)
)
data = [acoustic_data, time_to_failure]
graphJSON = json.dumps(data, cls=plotly.utils.PlotlyJSONEncoder)
return graphJSON
下面是一个示例,演示如何将示例绘图集成到Python Dash中。在
像这样的东西应该能让你达到目的。在
我用一些虚拟的数据在本地运行它,它工作了。如果你对此有任何困难,请告诉我。在
相关问题 更多 >
编程相关推荐