David 54321
David 54321

Reputation: 728

Fill Color Not Showing in Plotly due to Small Values

I have a dataset, I'm practicing with. I made it 60,000 lines long and the values in each line are relatively small. So when I look at it in a bar chart it doesn't look like there is fill and I'd really like to almost see it as a solid line/totaled amount. Also the reason I don't summarize it prior to charting it is that in practice I'd really like to be able to filter for different levels of data and for it to show up summarized. Any solutions to make a chart like this scalable?

import plotly.express as px
import pandas as pd

df = pd.DataFrame({
    "Fruit": ["Apples", "Orange", "Bananas", "Apples", "Oranges", "Bananas"],
    "Amount": [4, 1, 2, 2, 4, 5],
    "City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})
#this is just me trying to make a large dataset
df_append =[]
for i in range(10010):
    data = df
    df_append.append(data)
df = pd.concat(df_append)



fig = px.bar(df, x="Fruit", y="Amount", color='City')
fig.show()

enter image description here

Upvotes: 0

Views: 209

Answers (1)

Renaud
Renaud

Reputation: 2819

As it looks like you are seeing only thé separator lines, I think you need to perform a groupby before to plot

df=df.groupby(['City', 'Fruit'], as_index=False).sum()

Upvotes: 1

Related Questions