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.
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.
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.
how can I force a specific bar width across all my figure?
I donโt want to write fig.update_traces(width=1) every time.
take the width in range between 0 and 1,it will work