in plotly how can i adjust the blank size between my blocks

Viewed 76

Hello i try to do some graph with plotlib and there is my question: How can i remove the size between a and b, i want to fix the distance (example 0.5 em, 1% or i don't know). enter image description here

there is my code:

import plotly.graph_objects as px
import plotly.express as pd


 
x = ['<F0>s 4 à 8', '<F0>s  9 à 39', '<F0> 40']


plot = px.Figure(data=[
px.Bar(name = '1', x = x, y = [75, 75, 50], marker_color='#E5EBF7'),
px.Bar(name = '2', x = x, y = [75, 0, 50], marker_color='#D9CD9F'),
px.Bar(name = '3', x = x, y = [0, 75, 50], marker_color='#F7F4E9'),
])


plot.update_layout(barmode='stack')
plot.update_layout({
'plot_bgcolor': 'rgba(0, 0, 0, 0)',

})
plot.update_xaxes(color="black")
plot.update_xaxes(ticks="inside")
plot.show()
# plot.update_traces(line=dict(color="Black", width=0.5))


px.show()

I tried to check the documentation but they are too many thing and i am quite lost.

Thanks for yours answers!

1 Answers

You can add bargap attribute to update_layout like that:

 fig.update_layout(barmode='group',bargap=0.05)  

example with bargap=0.4:

fig.update_layout(barmode='group',bargap=0.4,autosize=False)

enter image description here

example with bargap=0.05:

fig.update_layout(barmode='group',bargap=0.05,autosize=False)

enter image description here

Related