# Bar Chart is not displayed correctly

**URL:** <https://community.plotly.com/t/bar-chart-is-not-displayed-correctly/33800>\
**Category:** Dash Python\
**Created:** [January 18, 2020, 7:24pm UTC](https://community.plotly.com/t/bar-chart-is-not-displayed-correctly/33800 "2020-01-18T19:24:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maeaex1](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Maeaex1](https://community.plotly.com/u/Maeaex1)\
**Post date:** [January 18, 2020, 7:24pm UTC](https://community.plotly.com/t/bar-chart-is-not-displayed-correctly/33800/1 "2020-01-18T19:24:39Z")

</div>

My bar chart in Dash does not display the whole bar but just a line marking the highest value of the corresponding bar.

 ![bar_chart](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/7/734274048f868f72240747d9decc90bd8aa477c3.jpeg)

Find below my code.  
The dataframe is normally set up, meaning for each X there is one Y

```auto
def update_graph3(start_date, end_date, selection):
    global df_r

    lag = 6

    df_r_filter = RC.create_timeseries(df_r, start_date, end_date, selection)

    df_weights = RC.create_portfolio_weights(df_r_filter, lag)
    mcr_rp, _, _ = RC.create_mcr(df_r_filter, 1_000_000, df_weights)

    fig = go.Figure(go.Box(
        x = mcr_rp.index,
        y = mcr_rp['Daily_d_VaR']))

    return fig

```

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![adamschroeder](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/adamschroeder/32/17280_2.png) [@adamschroeder](https://community.plotly.com/u/adamschroeder)\
**Post date:** [January 19, 2020, 1:07pm UTC](https://community.plotly.com/t/bar-chart-is-not-displayed-correctly/33800/2 "2020-01-19T13:07:15Z")

</div>

@Maeaex1  
Not sure, but I would recommend you try to print out your x,y values to see what you’re trying to plot. So, just above the “fig=go.Figure” insert the line:

```auto
print (mcr_rp.index)
print (mcr_rp['Daily_d_VaR'])

```

What do those printouts give you?

---

<div class="post-metadata">

**Author:** ![Maeaex1](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Maeaex1](https://community.plotly.com/u/Maeaex1)\
**Post date:** [January 19, 2020, 1:28pm UTC](https://community.plotly.com/t/bar-chart-is-not-displayed-correctly/33800/3 "2020-01-19T13:28:18Z")

</div>

Hey Adam,

```auto
Index(['HML', 'Momentum', 'CashFlow', 'SMB'], dtype='object')
HML 4999.633589
Momentum 7023.823656
CashFlow 13636.922602
SMB 1901.631649
Name: Daily_d_VaR, dtype: float64

```

The Output looks right to me or am I wrong?

Thanks for your help! Much appreciated!

---

<div class="post-metadata">

**Author:** ![adamschroeder](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/adamschroeder/32/17280_2.png) [@adamschroeder](https://community.plotly.com/u/adamschroeder)\
**Post date:** [January 19, 2020, 2:07pm UTC](https://community.plotly.com/t/bar-chart-is-not-displayed-correctly/33800/4 "2020-01-19T14:07:22Z")

</div>

Hi @Maeaex1  
Ok, I see. You’re missing data.

Your asking Plotly to create a Boxplot (not bar chart) with 4 categories on the x\_axis, but only 4 values on the y\_axis. That’s why you’re getting only one lines on the graph. You have only 1 numerical value for each category. The y\_axis usually has many values for each category, allowing the plot to generate a bar chart or boxplot.  
See this for examples: [Plotly-boxplots](https://plot.ly/python/box-plots/#box-plot-with-gobox)

---

<div class="post-metadata">

**Author:** ![Maeaex1](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Maeaex1](https://community.plotly.com/u/Maeaex1)\
**Post date:** [January 19, 2020, 2:15pm UTC](https://community.plotly.com/t/bar-chart-is-not-displayed-correctly/33800/5 "2020-01-19T14:15:15Z")

</div>

Thanks for the hint.

```auto

    trace = go.Bar(x = mcr.index,y = mcr['Daily_d_VaR'] )

    return {'data': [trace]}

```

Did the job! Wish you a nice sunday!
