我试图删除在 Python 中生成并使用 JS 在 HTML 中显示的绘图中的 ModeBar。根据文档,您可以指定一个配置,例如:
config = dict({'displayModeBar': False})
fig.show(config=config)
Run Code Online (Sandbox Code Playgroud)
但我将无花果导出到 json
graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)(不使用 .show() 函数)
然后用JS显示:
<script>
var graphs = {{graphJSON | safe}};
Plotly.newPlot('graph',graphs,{});
</script>
Run Code Online (Sandbox Code Playgroud)
我尝试在 newPlot 调用中指定一个配置,但没有成功,它似乎被忽略了:
Plotly.newPlot('graph',graphs,{},{displayModeBar: false});
Run Code Online (Sandbox Code Playgroud)
转换为 json 时如何指定配置选项?有没有其他方法可以摆脱ModeBar(鼠标悬停时显示的顶部栏)