Bar width using Plotly express

Is there a way to set the width of each bar, or all bars using plotly.express?

The working examples I managed to found people were using graph.object. I just don’t want rewrite my code.

Hi @guilhermeely,

This is how you can do it

import plotly.express as px
data_canada = px.data.gapminder().query("country == 'Canada'")
fig = px.bar(data_canada, x='year', y='pop')
fig.update_traces(width=1)
fig.show()

before updating figure:

after updating figure:

You should also have a look at the documentation, there are plenty of examples there:

hope this helps, Alex -

Thanks for the response.

Already tried that, the bars disappears if I do that.

1 Like

maybe you have set the width parameter too low, if you don’t provide any data I cannot help you further

Br, Alex

For the benefit of others landing on this page: when using the date type on the X axis the width units appear to be milliseconds.