Published (unlisted)
Insert cell
Insert cell
Changed in fork
-
md`First we define the y axis range on a variable called 'limit', and then a slider to allow us to modify the plot based on user input. The range for x-axis refers to the 'limit' variable, whereas the range for the y-axis is hardcoded in as [0, 1].
+
md`see https://talk.observablehq.com/t/plotly-graphs-dont-reset-after-zoom/2063
+
First we define the y axis range on a variable called 'limit', and then a slider to allow us to modify the plot based on user input. The range for x-axis refers to the 'limit' variable, whereas the range for the y-axis is hardcoded in as [0, 1].
Try zooming into the plot, and then use the slider to change the user input and thus reset the plot. The y-axis range resets, but the x-axis does not. Why? It you autoscale on the plot, using the overhead menu, this resets both axes. However, if you then try using the slider again, the x-axis gets zoomed in again. This is so weird! The only way to completely get rid of the problem is to reload the page and not zoom in. The expected behaviour is that both the x-axis and the y-axis range resets whenever the slider input is changed regardless of whether the axis range is hardcoded in or refers to a variable in another cell.`
Insert cell
Insert cell
Insert cell
Changed in fork
{ const data = [ { x: [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8], y: [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8] }, { x: [n], y: [n] } ]; const layout = { xaxis: {
-
range: limit
+
range: limit.slice()
}, yaxis: { range: [0, 1] }, width: width }; const div = DOM.element("div"); Plotly.newPlot(div, data, layout); return div; }
Insert cell
Insert cell
Insert cell