Recalculate axis tick values

Hi!

I have a UI where I have a button to switch between metric and imperial units. In context, assume I’m observing the acceleration of a car by plotting its velocity (in mph) against time. Is it possible to change the y axis’ values from mph to km/h through plot.ly?

My fallback approach is to recalculate server side and replot the entire graph.

Thanks!

You can try using Plotly.restyle. For example,

var graph = document.getElementById('graph')
var x = graph.data[0].x

Plotly.restyle(graph, 'x', [x.map(kmh2mph)])
1 Like

Brilliant, thank you! I will see if this will work tomorrow.