plotly / plotly_express

Plotly Express - Simple syntax for complex charts. Now integrated into plotly.py!
https://plot.ly/python/plotly-express/
MIT License
4 stars 0 forks source link

Some categories are not shown in polar bar chart #153

Closed nchelaru closed 4 years ago

nchelaru commented 4 years ago

Hello!

Fantastic work on the Plotly Express package! :)

I am trying to make a polar bar chart using Plotly Express, and have the chart animate by the year. The chart is supposed to show a breakdown of the various marketing campaigns (“AD”, “WEB”, “INSERTS”, etc) for each geographical region (“North”, “Northwest”, “Southwest”, etc).

Strangely, in some of the later years, the animated chart does not display data from certain categories like “WEB”, even though the data exists and these categories were displayed for the earlier years.

Here is a minimal example:

import plotly.express as px
import pandas as pd

df = pd.read_csv('https://github.com/nchelaru/plotly-dashboard/raw/master/polar_data.csv')

fig = px.bar_polar(df, r="totalprice", theta="polar",
                  color="channel", animation_frame='orderyear',
                  color_discrete_sequence=px.colors.sequential.Plasma)

fig.show()

Thanks in advance!

nicolaskruchten commented 4 years ago

Did you manage to resolve this or...? We haven't had a chance to look at it yet :)

nchelaru commented 4 years ago

Hi!

I did manage to solve it. It has to do with some data being missing for the earlier years, so even if they become available for later years, they will never show up. I used the solution here to insert 0's for these missing years, and it works well now.

Thank you so much for getting back to me!