Is there a way to decrease the inner padding of text shown on bar charts?

Hello,
I have a bar chart on which the font size of the text is limited because of the “inner padding”. Is there a way to decrease this padding? Will such a feature be available in the future?

The only workaround I can think of right now is hide text and display annotation, but it’s not perfect neither as the “outside/inside” feature is not available, and annotations don’t adapt when a trace it toggled on/off. (Stacked bars)

For intance on such a chart;
image

If I could show larger font, it would help. I cant because of this inner padding/margin.
I must either use annotation, or remove the 0. and mention in a legend that numbers are percentage x 100, etc.

Just in case, here is a MRE;

import plotly.graph_objects as go

months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
          #'Jan2', 'Feb2', 'Mar2', 'Apr2', 'May2', 'Jun2', 'Jul2', 'Aug2', 'Sep2', 'Oct2', 'Nov2', 'Dec2',
          'Jan3', 'Feb3', 'Mar3', 'Apr3', 'May3', 'Jun3', 'Jul3', 'Aug3', 'Sep3', 'Oct3', 'Nov3', 'Dec3']
y_val_a = [.20, .14, .25, .16, .18, .22, .19, .15, .12, .16, .14, .17,
           #.20, .14, .25, .16, .18, .22, .19, .15, .12, .16, .14, .17,
           .20, .14, .25, .16, .18, .22, .19, .15, .12, .16, .14, .17]

y_val_b = [.19, .14, .22, .14, .16, .19, .15, .14, .10, .12, .12, .16,
           #.19, .14, .22, .14, .16, .19, .15, .14, .10, .12, .12, .16,
           .19, .14, .22, .14, .16, .19, .15, .14, .10, .12, .12, .16]


fig = go.Figure()
fig.add_trace(go.Bar(
    x=months,
    y=y_val_a,
    text=y_val_a,
    name='Primary Product',
    marker_color='indianred',
    textfont=dict(size=14)

))
fig.add_trace(go.Bar(
    x=months,
    y=y_val_b,
    text=y_val_b,
    name='Secondary Product',
    marker_color='lightsalmon'
))

# Here we modify the tickangle of the xaxis, resulting in rotated labels.
fig.update_layout(barmode='group', xaxis_tickangle=-45, yaxis_range=[0,1])
fig.show()

Posting here as I finally found a solution, using the “mode” “show” of uniformtext, and setting the minsize to something small and readable.

  • uniformtext
    Code: fig.update_layout(uniformtext=dict(...))
    Type: dict containing one or more of the keys listed below.
    • minsize
      Code: fig.update_layout(uniformtext_minsize=<VALUE>)
      Type: number greater than or equal to 0
      Default: 0 Sets the minimum text size between traces of the same type.
    • mode
      Code: fig.update_layout(uniformtext_mode=<VALUE>)
      Type: enumerated , one of ( False | "hide" | "show" )Determines how the font size for various text elements are uniformed between each trace type. If the computed text sizes were smaller than the minimum size defined by uniformtext.minsize using “hide” option hides the text; and using “show” option shows the text without further downscaling. Please note that if the size defined by minsize is greater than the font size defined by trace, then the minsize is used.
1 Like