Plot - show numbers in the plot in millions

Hey

How can I show numbers in the plot in millions ?

How are you creating the bar chart? If it in express, then text_auto=True would use the same units as the y-axis. Otherwise you can provide a format string to it, like `text_auto=.3s" (SI format with 3 significative digits, so 1225110 => 1.22M).

If you are using graph objects, then you can specify the texttemplate for the trace by adding texttemplate='%{text:.3s}' in go.Bar(same format as above), or using fig.update_traces(texttemplate= '%{text:.3s}').

The format follows the d3-format notation, which can be a bit tricky to figure out in special cases (so now you know where this comes from).

1 Like