# Bar chart with very thin bars

**URL:** <https://community.plotly.com/t/bar-chart-with-very-thin-bars/79889>\
**Category:** 📊 Plotly Python\
**Created:** [November 6, 2023, 3:52pm UTC](https://community.plotly.com/t/bar-chart-with-very-thin-bars/79889 "2023-11-06T15:52:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabino.alonso](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/gabino.alonso/32/26732_2.png) [@gabino.alonso](https://community.plotly.com/u/gabino.alonso)\
**Post date:** [November 6, 2023, 3:52pm UTC](https://community.plotly.com/t/bar-chart-with-very-thin-bars/79889/1 "2023-11-06T15:52:24Z")

</div>

Hello all,  
my problem is that when I view my bar chart, the bars appear very thin and you can hardly see them.

i have this \>\>

 ![newplot](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/a/4/a457157c0387744aa458a58a21c62841a29c5dce.png)

and this is my sample code:

```auto
df_test = pd.read_csv('test_data.csv')
media = round(df_test["ok"].mean())
title = "Cantidad por producciones (OK medio = {})".format(media)
fig = px.bar(df_test,
                x = 'inicio',
                y="ok",
                hover_data=['id', 'inicio', 'ok', 'nok'],
                color='maquina',
                title=title)

fig.add_hline(y=media, line_color='darkblue', line_width=2, line_dash="dot", opacity=0.5)

fig.update_layout(showlegend=True,
                      hoverlabel_align = 'right',
                      xaxis_title= None,
                      yaxis_title= None,
                      hovermode="x unified",
                      plot_bgcolor="#f9f9f9",
                      paper_bgcolor="#f9f9f9",
                      margin=dict(l=30, r=0, t=30, b=10)
    )

```

---

<div class="post-metadata">

**Author:** ![Berbere](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/berbere/32/25940_2.png) [@Berbere](https://community.plotly.com/u/Berbere)\
**Post date:** [November 6, 2023, 4:43pm UTC](https://community.plotly.com/t/bar-chart-with-very-thin-bars/79889/2 "2023-11-06T16:43:52Z")

</div>

Hey @gabino.alonso

Try experimenting with the width property of the bar component.

`fig.update_traces(width=1)`

It should work… If not, do not hesitate to ask again!

Cheers!

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [November 6, 2023, 4:46pm UTC](https://community.plotly.com/t/bar-chart-with-very-thin-bars/79889/3 "2023-11-06T16:46:44Z")

</div>

See also:

> [@How to limit bar width with time-series axis](https://community.plotly.com/t/how-to-limit-bar-width-with-time-series-axis/76766/4):
>
> Hi, you have a strange way of putting your Figure together mixing up plotly.express and plotly.graph\_objects Here is how I would do this, the width parameter is what you are looking for. Since you are using a time axis, the width has to be specified in milliseconds: from pandas import DataFrame import plotly.graph\_objects as go dtf = DataFrame({"hour": ["2023-07-10 17:00:00+08:00", "2023-07-10 21:00:00+08:00"], "number": [2, 5]}) fig = go.Figure(go.Bar(x=dtf.hour, y=dtf.number, width=3\_600\_0…

Related:

> [@Unable to enhance width of bars in a stacked barchart (plotly graph objects)](https://community.plotly.com/t/unable-to-enhance-width-of-bars-in-a-stacked-barchart-plotly-graph-objects/75857):
>
> Hello, The following code produces a stacked bar-chart. However I am unable to increase the width of the bars produced. I have used the width parameter as discussed in documentation but it isn’t helping. The code is as follows: #python import datetime import plotly.graph\_objects as go from numpy import array def plot\_barchart(title\_p: str, x\_label: str, y\_label: str): barchart\_fig\_go = go.Figure(layout=go.Layout(plot\_bgcolor='#FFFFFF')) barchart\_fig\_go.add\_trace( …

> [@Unstacking grouped plot creates huge gap between groups. PlotlyExpress](https://community.plotly.com/t/unstacking-grouped-plot-creates-huge-gap-between-groups-plotlyexpress/69698):
>
> Hey peeps! As you can see from the first image my plot is nice and readable, but i’d like to unstack these to be able to easier seperate things. But when i do the gap between the groups becomes huge, i’ve tried searching the forums and google but i’m not able to find any result… I have tried bargap and bargroupgap without any difference, both in “update\_layout” and directly in the plot. with barmod=‘group’ df = pd.read\_parquet("parquets/df.parquet") fig = px.bar(d…

---

<div class="post-metadata">

**Author:** ![gabino.alonso](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/gabino.alonso/32/26732_2.png) [@gabino.alonso](https://community.plotly.com/u/gabino.alonso)\
**Post date:** [November 7, 2023, 8:48am UTC](https://community.plotly.com/t/bar-chart-with-very-thin-bars/79889/4 "2023-11-07T08:48:47Z")

</div>

Thanks to both of you, I’m going to try it and share my experience.

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [November 7, 2023, 9:43am UTC](https://community.plotly.com/t/bar-chart-with-very-thin-bars/79889/5 "2023-11-07T09:43:36Z")

</div>

> [@Berbere](#):
>
> Try experimenting with the width property of the bar component.
> 
> `fig.update_traces(width=1)`
> 
> It should work… If not, do not hesitate to ask again!

Just for information:  
If using a time axis, the width has to be specified in milliseconds 🙌
