[英]plotly-dash: How to get predefined yaxis range after zoom out?
When I create a graph in plotly-dash, I define a fix range for the yaxis:当我在 plotly-dash 中创建图形时,我为 yaxis 定义了一个固定范围:
...
'layout': go.Layout(title='Graph', xaxis=dict(title="Time"), yaxis=dict(... , range=[0, 100], ...),
...
This works fine.这工作正常。
But after a zoomout event (doubleclick in the chart) the yaxis is autoscaled by the given data range.但是在缩小事件(在图表中双击)之后,yaxis 会根据给定的数据范围自动缩放。 Is there a way to turn the autoscaling on zoomout off?
有没有办法在缩小时关闭自动缩放? Or exists any other way to solve this problem?
或者有没有其他方法可以解决这个问题?
go.Layout and eg go.Scatter
are eventually passed to go.Figure
. go.Layout 和例如
go.Scatter
最终会传递给go.Figure
。 In dash the go.Figure object is than passed on to dcc.Graph
.在 dash 中, go.Figure 对象被传递给
dcc.Graph
。
dcc.Graph
accepts an config argument which is able to set which buttons to show, logo, how events are handled and much more. dcc.Graph
接受一个配置参数,它能够设置要显示的按钮、徽标、事件的处理方式等等。
from the doc-string of dcc.Graph
:来自
dcc.Graph
的文档字符串:
- doubleClick (a value equal to: false, 'reset', 'autosize', 'reset+autosize'; optional): Double click interaction (false, 'reset', 'autosize' or 'reset+autosize')
example例子
dcc.Graph(
figure=go.Figure(data, layout),
config={'doubleClick': 'autosize'}
)
abbreviations :缩写:
dcc short for dash_core_components
go short for plotly.graph_objs
references :参考资料:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.