Can I add a custom mod bar button?

I have a function that auto scales the y axis. It takes in the figure and relayout data objects and then spits out a y axis that fits some criteria that I pre-determined. I want to add a new modbar button in dash plotly on python that fires the function and updates the figure any time I click on it. Is that possible?

It looks like this same question came up two years ago but there was no answer Custom modeBar Buttons in Python

To my knowledge, you can’t add custom modebar buttons through python. You can in plotly.Js.

You can add a button to the modebar in JavaScript with a clientside_callback, but again, it is a JavaScript interaction.

Can I add the javascript to the main.js file? I have other javascript in there that interacts with my plotly python dashboard

Yes, you can. But it might be easier to implement with a clientside callback.

Hmm… I’m not sure what you mean. Can I add a callback that’s attached to the modbar button? I’d just like to get rid of the autoresize part of the button

Take a look at this post, in it I add a custom button to the modebar group whenever the page loads or there is an update to the dash components.

But, you could instead use a clientside_callback to add the button upon the dcc.Graph populating.

At that point, you can design the button to look however you want to. :grin: