I have two horizontal bar charts in my Dash App which looks like:
I would like to reduce all this space and get something like:
I have set the margins to 0 but it doesnt reduce the empty space.
Here the function to produce these bars:
def Bar_Figure(bar_traces, annotations):
figure = {
'data':bar_traces,
'layout':go.Layout(
annotations = annotations,
height=300,
xaxis=dict(
showgrid=False,
showline=False,
showticklabels=False,
zeroline=False,
domain=[0.15, 1]
),
yaxis=dict(
showgrid=False,
showline=False,
showticklabels=False,
zeroline=False,
),
barmode='stack',
paper_bgcolor =('#fafafa'),
plot_bgcolor=("#fafafa"),
margin=dict(
l=0,
r=100,
t=0,
b=0
),
showlegend=True,
),
}
return figure
def Bar_Traces(y_bars, df_selected,bar_names):
bar_traces = []
for i in range(0, len(df_selected[0])):
for xd, yd in zip(df_selected, y_bars):
bar_traces.append(go.Bar(
name=bar_names[i],
x=[xd[i]],
y=[yd],
width = [0.1],
orientation='h',
marker=dict(
color=bar_colors[i],
line=dict(
color='rgb(248, 248, 249)',
width=1)
)
))
return bar_traces
and here the calls:
bar_fig_1 = Bar_Figure(bar_1_traces, annot_bar_1)
bar_fig_2 = Bar_Figure(bar_2_traces, annot_bar_2)
bar_fig_1_return = html.Div(dcc.Graph(figure=bar_fig_1))
bar_fig_2_return = html.Div(dcc.Graph(figure=bar_fig_2))