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;
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()