Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

Change axis scale (e.g. from Kilometers to Meters)

I am looking for way to change the scale of a simple x y line plot.

The y axis contains the values in units of meters but I would like to be able to change the plotted units with a afew simple html radio buttons

I would like to update the plot with the new scale one each radio button is pressed

any tips or suggestions are much appreciated

I would imagine I can use the var update and plotly.relayout but I can’t find a scale option

var update = {
xaxis: {
title: ‘Distance in meters’,
Plotly.relayout(‘myDiv’, update)

Many thanks

1 Like

Unfortunately, plotly.js doesn’t offer an easy way to scale its axes.

I’d recommend replotting with scaled data instead:

1 Like

Thanks for the answer I’m now trying to adapt it so that it can find all the traces and then scale them all