plotly-dash - 为什么 plotly 的配置在 dash 中不起作用?
问题描述
当我使用fig.show
时,会显示模式栏按钮,但是当我尝试对破折号执行相同操作时,它不起作用。我尝试了很多选择,但它似乎不起作用。文档也不完整。顺便说一下,这些是内置按钮,而不是自定义按钮。
我在教程中看到了这个:
fig.show(config={'modeBarButtonsToAdd':['drawline',
'drawopenpath',
'drawclosedpath',
'drawcircle',
'drawrect',
'eraseshape'
]})
然后,我尝试在 dash 而不是 dash 中输入相同的内容fig.show
,但它不起作用!
app.layout = html.Div([
dcc.Graph(
id='mainPlot',
figure=fig,
config={'modeBarButtonsToAdd':['drawline',
'drawopenpath',
'drawclosedpath',
'drawcircle',
'drawrect',
'eraseshape'
]}
)
])
这是 MWE:我想通过and not传递config
with 。它适用于按钮是内置的,但不适用于配置传递,因为我收到错误说按钮需要使用名称、单击功能等进行定义,并且被视为自定义按钮而不是启用内置按钮.modeBarButtonsToAdd
config
app.layout
fig.show
fig.show
app.layout
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div(children=[
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
解决方案
安装最新版本的 dash 应该可以解决您的问题。
推荐阅读
- python - BeautifulSoup 不处理锚标记内的 HTML 表
- python - 使用 Python 自动处理 dymola 模拟结果
- c - 分配二维数组(类型 char)为浮点计算准备内存
- reactjs - 停止 React Google 自动完成组件重新渲染,但在选择时渲染其他所有内容
- sql - Hive 窗口功能:将组 id 分配给重叠组
- .net-core - 如何使用 Steeltoe Actuator + opencensus + Prometheus 使用指标
- css - 如何仅使用一个元素 - div 制作图片?
- vue.js - 显示存储在我的后端服务器上的图像
- amazon-web-services - 如何跨账户访问 Lambda 函数?
- windows - 关闭日志记录窗口