Black Lives Matter. Please consider donating to Campaign Zero's mission of ending police violence in America.

How to set the exponentformat?

Hey there,

I’d like to change the exponentformat on the x-axis. It appears that the exponentformat property is now on marker.colorbar (in a scatter plot that is). Can you provide a small example how to use it? I have tried different approaches but none have worked so far.

Thanks in advance!

Through some debugging, I’ve found a solution I’m happy with:
if (xAxisIsTimeBased) { this.layout.xaxis.tickformat = ''; this.layout.xaxis.type = 'date'; this.layout.xaxis.exponentformat = 'B'; } else if (xAxisIsPlainNumberBased) { this.layout.xaxis.type = undefined; this.layout.xaxis.tickformat = '{:d}'; this.layout.xaxis.exponentformat = 'none'; }

this.layout refers to the layout object you would provide in a call to Plotly.newPlot(plotlyElem, yourData, layout);
Important here is the xaxis.type attribute which makes the x-axis use a time-based scale.

More info: