# Unable to plot histogram dataframe (y axes count, x axes label)

**URL:** <https://community.plotly.com/t/unable-to-plot-histogram-dataframe-y-axes-count-x-axes-label/10469>\
**Category:** 📊 Plotly Python\
**Created:** [May 24, 2018, 9:50am UTC](https://community.plotly.com/t/unable-to-plot-histogram-dataframe-y-axes-count-x-axes-label/10469 "2018-05-24T09:50:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anitto](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@anitto](https://community.plotly.com/u/anitto)\
**Post date:** [May 24, 2018, 9:50am UTC](https://community.plotly.com/t/unable-to-plot-histogram-dataframe-y-axes-count-x-axes-label/10469/1 "2018-05-24T09:50:44Z")

</div>

Hi there  
I should plot a count bar chart of Dataframe generated from a dict.  
Here is my code:

```
import plotly.offline as py
import plotly.graph_objs as go
import numpy as np
import pandas as pd

#use the next line if you are using notebook
py.init_notebook_mode(connected=True)

d = {'facebook': 1876, 'twitter': 512, 'linkedin': 8, 'pinterest': 18, 'google+': 97, 'instagram': 145}
count_social = pd.DataFrame.from_dict(d,orient='index')
count_social.columns= ['social']

data = [go.Histogram(x=count_social['social'],
                     histnorm='count',
                     name='Social accounts'
                    )]

# IPython notebook
layout = go.Layout(
    bargap=0.2,
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)

```

I want six bin on x axes (one for each social network) and count of in y values, but I am unable to get it.

Any help is appreciated!  
Thanks

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [June 7, 2018, 12:07pm UTC](https://community.plotly.com/t/unable-to-plot-histogram-dataframe-y-axes-count-x-axes-label/10469/2 "2018-06-07T12:07:43Z")

</div>

Hi @anitto,

Since you already know the heights of each bar (the count) you can actually use a plain `Bar` trace rather than a `Histogram` trace. For example

```python
import plotly.offline as py
import plotly.graph_objs as go
import numpy as np
import pandas as pd

#use the next line if you are using notebook
py.init_notebook_mode(connected=True)

d = {'facebook': 1876, 'twitter': 512, 'linkedin': 8, 'pinterest': 18, 'google+': 97, 'instagram': 145}
count_social = pd.DataFrame.from_dict(d,orient='index')
count_social.columns= ['social']

data = [go.Bar(x=count_social.index,
               y=count_social['social'],
               name='Social accounts')]

# IPython notebook
layout = go.Layout(
    bargap=0.2,
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)

```

 ![newplot-3](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/5/524c67b7769ff017efc542c6b1769890cecd7529.png)

The `Histogram` trace would be useful if you were starting with a list of social networks and you hadn’t yet determined the number of times each one appears. For example:

```python
data = [go.Histogram(
    x=['facebook', 'facebook', 'facebook',
       'twitter',
       'linkedin', 'linkedin'],
    name='Social accounts')]

# IPython notebook
layout = go.Layout(
    bargap=0.2,
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)

```

 ![newplot-4](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/9/9a49d9554577051ab94a10393453b3f841d21630.png)

I hope that helps clear things up a bit!
