0
votes

When I create a graph in plotly-dash, I define a fix range for the 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. Is there a way to turn the autoscaling on zoomout off? Or exists any other way to solve this problem?

1

1 Answers

1
votes

go.Layout and e.g. go.Scatter are eventually passed to go.Figure. In dash the go.Figure object is than passed on to 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.

from the doc-string of 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: